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 网络编程
7,764 每月下载量
用于 netavark
20KB
442 行
Rust iptables
此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