Crates.io | rust-iptables |
lib.rs | rust-iptables |
version | 0.0.2 |
source | src |
created_at | 2021-10-22 11:01:17.483619 |
updated_at | 2021-10-25 11:52:54.039806 |
description | A iptables bindings for Rust. |
homepage | |
repository | |
max_upload_size | |
id | 469280 |
size | 29,274 |
A iptables bindings for Rust.
Rust bindings for iptables, it provides a few major components:
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.
This library is verified to work in rustc 1.51.0 (nightly), and the support of other versions needs more testing.
This project is licensed under the Apache License 2.0.