rust-iptables 0.0.2

A iptables bindings for Rust.
Documentation
  • Coverage
  • 0%
    0 out of 42 items documented0 out of 29 items with examples
  • Size
  • Source code size: 28.75 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.56 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • inkhare

rust-iptables

A iptables bindings for Rust.

Overview

Rust bindings for iptables, it provides a few major components:

  • high-level handles, such as save/restore
  • table/chain/rule support
  • IPv4/IPv6 support

Example

A basic chain/table example.

[dependencies]
rust-iptables = { version = "0.0.2" }

Then, on your main.rs:

use rust_iptables::iptables;

fn main() {
    let ipt = iptables::new().unwrap();

    assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
    assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
    assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
    assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
    assert!(ipt.save_all("test").is_ok());
    assert!(ipt.restore_all("test").is_ok());
    assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());

    assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
}

More examples can be found here.

Supported Rust Versions

This library is verified to work in rustc 1.51.0 (nightly), and the support of other versions needs more testing.

License

This project is licensed under the Apache License 2.0.