#netfilter #bindings #api-bindings

iptables

Rust对iptables的绑定

14个版本

0.5.2 2024年6月6日
0.5.1 2023年9月18日
0.5.0 2022年2月1日
0.4.3 2021年3月7日
0.1.2 2017年2月11日

#278 in 网络编程

Download history 1534/week @ 2024-05-03 1652/week @ 2024-05-10 1703/week @ 2024-05-17 1405/week @ 2024-05-24 1498/week @ 2024-05-31 1222/week @ 2024-06-07 1120/week @ 2024-06-14 1386/week @ 2024-06-21 1401/week @ 2024-06-28 1616/week @ 2024-07-05 2093/week @ 2024-07-12 1653/week @ 2024-07-19 2129/week @ 2024-07-26 1787/week @ 2024-08-02 1806/week @ 2024-08-09 1790/week @ 2024-08-16

7,764 每月下载量
用于 netavark

MIT 许可证

20KB
442

Rust iptables

crates.io Documentation Build License

此crate为Linux中的iptables应用程序提供绑定(灵感来自go-iptables)。此crate使用iptables二进制文件来操作链和表。此源代码根据MIT许可证进行许可,许可证可在LICENSE文件中找到。

[dependencies]
iptables = "*"

入门

1- 导入crate iptables 并操作链

let ipt = iptables::new(false).unwrap();

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

有关更多信息,请参阅tests文件夹中的测试文件。

依赖关系

~4.5MB
~88K SLoC