diff --git a/Cargo.toml b/Cargo.toml index 47b2e44..0195d52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tun2" -version = "3.1.4" +version = "3.1.5" edition = "2021" authors = ["meh. ", "@ssrlive"] license = "WTFPL" diff --git a/src/platform/windows/device.rs b/src/platform/windows/device.rs index 8fc1078..23df0be 100644 --- a/src/platform/windows/device.rs +++ b/src/platform/windows/device.rs @@ -48,7 +48,7 @@ impl Device { Err(_) => Adapter::create(&wintun, tun_name, tun_name, guid)?, }; if let Some(metric) = config.metric { - // Command: netsh interface ip set interface {index} metric={metric} + // command: netsh interface ip set interface {index} metric={metric} let i = adapter.get_adapter_index()?.to_string(); let m = format!("metric={}", metric); run_command("netsh", &["interface", "ip", "set", "interface", &i, &m])?; diff --git a/src/run_command.rs b/src/run_command.rs index cdd5d35..3e62216 100644 --- a/src/run_command.rs +++ b/src/run_command.rs @@ -2,14 +2,23 @@ #[doc(hidden)] #[allow(dead_code)] 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, 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)