5 releases

0.1.5 Aug 8, 2022
0.1.4 Aug 3, 2022
0.1.2 Aug 2, 2022
0.1.1 Aug 2, 2022
0.1.0 Aug 2, 2022

#7 in #iptables

MIT license

9KB
141 lines

ipset-sys

crate.io

A small crate to talk to ipset from rust.

supports both regular libipset commands, and custom/faster handler for adding ipv4 to sets

Example

    use ipset_sys::IpsetSys;

    fn main() {
        let mut is = IpsetSys::init().unwrap()

        // regular libipset command
        is.run("create bob hash:ip timeout 3600").unwrap()

        // custom ipv4 handler to add to a set
        let addr = std::net::Ipv4Addr::new(1, 4, 4, 4);
        is.add_v4("bob", addr).unwrap()

        is.run("destroy bob").unwrap();
 }

lib.rs:

A small crate to talk to ipset from rust.

supports both regular libipset commands, and custom/faster handler for adding ipv4 to sets

Example

use ipset_sys::IpsetSys;

fn main() {
    let mut is = IpsetSys::init().unwrap();

    // regular libipset command
    is.run("create bob hash:ip timeout 3600").unwrap();

    // custom ipv4 handler to add to a set
    let addr = std::net::Ipv4Addr::new(1, 4, 4, 4);
    is.add_v4("bob", addr).unwrap();

    is.run("destroy bob").unwrap();
}

Dependencies

~0.3–2.5MB
~53K SLoC