diff --git a/src/lib.rs b/src/lib.rs index 4a4d6dc..1060f63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,14 +92,14 @@ pub struct IPTables { pub is_numeric: bool, } -/// Returns `None` because iptables only works on linux -#[cfg(not(target_os = "linux"))] -pub fn new(is_ipv6: bool) -> Result> { - Err(error_from_str("iptables only works on Linux")) +/// Returns an error because iptables only works on Linux-based systems +#[cfg(not(any(target_os = "linux", target_os = "android")))] +pub fn new(_is_ipv6: bool) -> Result> { + Err(error_from_str("iptables only works on Linux-based systems")) } /// Creates a new `IPTables` Result with the command of 'iptables' if `is_ipv6` is `false`, otherwise the command is 'ip6tables'. -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] pub fn new(is_ipv6: bool) -> Result> { let cmd = if is_ipv6 { "ip6tables" } else { "iptables" }; @@ -184,7 +184,7 @@ impl IPTables { /// Checks for the existence of the `rule` in the table/chain. /// Returns true if the rule exists. - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub fn exists(&self, table: &str, chain: &str, rule: &str) -> Result> { if !self.has_check { return self.exists_old_version(table, chain, rule); @@ -196,7 +196,7 @@ impl IPTables { /// Checks for the existence of the `chain` in the table. /// Returns true if the chain exists. - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] pub fn chain_exists(&self, table: &str, chain: &str) -> Result> { match self.is_numeric { false => self