Skip to content

Commit

Permalink
add new_with_cmd to be able to control which iptables binary is bei…
Browse files Browse the repository at this point in the history
…ng used
  • Loading branch information
aviramha committed Feb 26, 2024
1 parent 403afe0 commit 111f259
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ pub fn new(is_ipv6: bool) -> Result<IPTables, Box<dyn Error>> {
#[cfg(target_os = "linux")]
pub fn new(is_ipv6: bool) -> Result<IPTables, Box<dyn Error>> {
let cmd = if is_ipv6 { "ip6tables" } else { "iptables" };
new_with_cmd(cmd)
}

#[cfg(target_os = "linux")]
pub fn new_with_cmd(cmd: &'static str) -> Result<IPTables, Box<dyn Error>> {
let version_output = Command::new(cmd).arg("--version").output()?;
let re = Regex::new(r"v(\d+)\.(\d+)\.(\d+)")?;
let version_string = String::from_utf8_lossy(version_output.stdout.as_slice());
Expand Down

0 comments on commit 111f259

Please sign in to comment.