From 111f25916c4a44d91f8b48403f3783d9ad8fd5ef Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Mon, 26 Feb 2024 17:38:30 +0200 Subject: [PATCH] add `new_with_cmd` to be able to control which iptables binary is being used --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2684822..75f2d46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,7 +105,11 @@ pub fn new(is_ipv6: bool) -> Result> { #[cfg(target_os = "linux")] pub fn new(is_ipv6: bool) -> Result> { 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> { 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());