rust-iptables
rust-iptables copied to clipboard
Add `flush_tables`
Flush tables via iptables -F
command without requiring specific tables.
A more drastic measure that can be taken instead of adding a function can be used:
pub fn flush_table(&self, table: Option<&str>) -> Result<(), Box<dyn Error>> {
if table.is_none() {
return self.run(&["-F"]).and_then(output_to_result);
}
self.run(&["-t", table, "-F"]).and_then(output_to_result)
}
While a breaking change this would require people to memorize one less function, this would also be a fairly trivial fix for people to wrap table
in their calls to flush_table
with Some()
.
// new call
ipt.flush_table(Some("table"));