pub struct IPTables {
pub cmd: &'static str,
pub save_cmd: &'static str,
pub restore_cmd: &'static str,
pub has_check: bool,
pub has_wait: bool,
pub v_major: isize,
pub v_minor: isize,
pub v_patch: isize,
}
Fields§
§cmd: &'static str
§save_cmd: &'static str
§restore_cmd: &'static str
§has_check: bool
§has_wait: bool
§v_major: isize
§v_minor: isize
§v_patch: isize
Implementations§
Source§impl IPTables
impl IPTables
pub fn save_table( &self, table: &str, target: &str, ) -> Result<Output, Box<dyn Error>>
Sourcepub fn save_all(&self, target: &str) -> Result<Output, Box<dyn Error>>
pub fn save_all(&self, target: &str) -> Result<Output, Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 10)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn restore_table( &self, table: &str, target: &str, ) -> Result<Output, Box<dyn Error>>
Sourcepub fn restore_all(&self, target: &str) -> Result<Output, Box<dyn Error>>
pub fn restore_all(&self, target: &str) -> Result<Output, Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 11)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
Source§impl IPTables
impl IPTables
Sourcepub fn exists(
&self,
table: &str,
chain: &str,
rule: &str,
) -> Result<bool, Box<dyn Error>>
pub fn exists( &self, table: &str, chain: &str, rule: &str, ) -> Result<bool, Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 8)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn insert( &self, table: &str, chain: &str, position: i32, rule: &str, ) -> Result<(), Box<dyn Error>>
Sourcepub fn append(
&self,
table: &str,
chain: &str,
rule: &str,
) -> Result<(), Box<dyn Error>>
pub fn append( &self, table: &str, chain: &str, rule: &str, ) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 7)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn append_unique( &self, table: &str, chain: &str, rule: &str, ) -> Result<(), Box<dyn Error>>
Sourcepub fn delete(
&self,
table: &str,
chain: &str,
rule: &str,
) -> Result<(), Box<dyn Error>>
pub fn delete( &self, table: &str, chain: &str, rule: &str, ) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 9)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn delete_if_exsits( &self, table: &str, chain: &str, rule: &str, ) -> Result<(), Box<dyn Error>>
pub fn list( &self, table: &str, chain: &str, ) -> Result<Vec<String>, Box<dyn Error>>
pub fn list_with_counters( &self, table: &str, chain: &str, ) -> Result<Vec<String>, Box<dyn Error>>
pub fn list_chains(&self, table: &str) -> Result<Vec<String>, Box<dyn Error>>
pub fn chain_exists( &self, table: &str, chain: &str, ) -> Result<bool, Box<dyn Error>>
Sourcepub fn new_chain(&self, table: &str, chain: &str) -> Result<(), Box<dyn Error>>
pub fn new_chain(&self, table: &str, chain: &str) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 6)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn flush_chain( &self, table: &str, chain: &str, ) -> Result<(), Box<dyn Error>>
pub fn rename_chain( &self, table: &str, old_chain: &str, new_chain: &str, ) -> Result<(), Box<dyn Error>>
Sourcepub fn delete_chain(
&self,
table: &str,
chain: &str,
) -> Result<(), Box<dyn Error>>
pub fn delete_chain( &self, table: &str, chain: &str, ) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 12)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn flush_and_delete_chain( &self, table: &str, chain: &str, ) -> Result<(), Box<dyn Error>>
pub fn flush_table(&self, table: &str) -> Result<(), Box<dyn Error>>
pub fn delete_table(&self, table: &str) -> Result<(), Box<dyn Error>>
pub fn flush_all(&self) -> Result<(), Box<dyn Error>>
pub fn delete_all(&self) -> Result<(), Box<dyn Error>>
Sourcepub fn change_policy(
&self,
table: &str,
chain: &str,
target: &str,
) -> Result<(), Box<dyn Error>>
pub fn change_policy( &self, table: &str, chain: &str, target: &str, ) -> Result<(), Box<dyn Error>>
Examples found in repository?
examples/table.rs (line 14)
3fn main() {
4 let ipt = iptables::new().unwrap();
5
6 assert!(ipt.new_chain("nat", "TESTINGCHAIN").is_ok());
7 assert!(ipt.append("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
8 assert!(ipt.exists("nat", "TESTINGCHAIN", "-j ACCEPT").unwrap());
9 assert!(ipt.delete("nat", "TESTINGCHAIN", "-j ACCEPT").is_ok());
10 assert!(ipt.save_all("test").is_ok());
11 assert!(ipt.restore_all("test").is_ok());
12 assert!(ipt.delete_chain("nat", "TESTINGCHAIN").is_ok());
13
14 assert!(ipt.change_policy("filter", "FORWARD", "ACCEPT").is_ok());
15}
pub fn get_iptables_version(self) -> (isize, isize, isize)
Auto Trait Implementations§
impl Freeze for IPTables
impl RefUnwindSafe for IPTables
impl Send for IPTables
impl Sync for IPTables
impl Unpin for IPTables
impl UnwindSafe for IPTables
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more