diff --git a/Cargo.toml b/Cargo.toml index f8fcf23..e75513b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wintun-bindings" -version = "0.7.9" +version = "0.7.10" edition = "2021" authors = [ "ssrlive", diff --git a/src/adapter.rs b/src/adapter.rs index ac2e36e..e304ac0 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -252,7 +252,7 @@ impl Adapter { gateway: Option, ) -> Result<(), Error> { let name = self.get_name()?; - // Command line: `netsh interface ipv4 set address name="YOUR_INTERFACE_NAME" source=static address=IP_ADDRESS mask=SUBNET_MASK gateway=GATEWAY` + // command line: `netsh interface ipv4 set address name="YOUR_INTERFACE_NAME" source=static address=IP_ADDRESS mask=SUBNET_MASK gateway=GATEWAY` // or shorter command: `netsh interface ipv4 set address name="YOUR_INTERFACE_NAME" static IP_ADDRESS SUBNET_MASK GATEWAY` // for example: `netsh interface ipv4 set address name="Wi-Fi" static 192.168.3.8 255.255.255.0 192.168.3.1` let mut args: Vec = vec![ diff --git a/src/util.rs b/src/util.rs index 6512bb7..8f87907 100644 --- a/src/util.rs +++ b/src/util.rs @@ -406,14 +406,23 @@ pub(crate) fn set_adapter_mtu(name: &str, mtu: usize) -> std::io::Result<()> { /// Runs a command and returns an error if the command fails, just convenience for users. pub fn run_command(command: &str, args: &[&str]) -> std::io::Result> { - let out = std::process::Command::new(command).args(args).output()?; + let full_cmd = format!("{} {}", command, args.join(" ")); + log::debug!("Running command: \"{full_cmd}\"..."); + let out = match std::process::Command::new(command).args(args).output() { + Ok(out) => out, + Err(e) => { + log::error!("Run command: \"{full_cmd}\" failed with: \"{e}\""); + return Err(e); + } + }; if !out.status.success() { let err = String::from_utf8_lossy(if out.stderr.is_empty() { &out.stdout } else { &out.stderr }); - let info = format!("{} {} failed with: \"{}\"", command, args.join(" "), err); + let info = format!("Run command: \"{full_cmd}\" failed with \"{err}\""); + log::error!("{}", info); return Err(std::io::Error::new(std::io::ErrorKind::Other, info)); } Ok(out.stdout)