Skip to content

Commit

Permalink
Bump version 3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Sep 27, 2024
1 parent e5f44c3 commit eb6c8dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tun2"
version = "3.1.4"
version = "3.1.5"
edition = "2021"
authors = ["meh. <meh@schizofreni.co>", "@ssrlive"]
license = "WTFPL"
Expand Down
2 changes: 1 addition & 1 deletion src/platform/windows/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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])?;
Expand Down
13 changes: 11 additions & 2 deletions src/run_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
#[doc(hidden)]
#[allow(dead_code)]
pub fn run_command(command: &str, args: &[&str]) -> std::io::Result<Vec<u8>> {
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)
Expand Down

0 comments on commit eb6c8dc

Please sign in to comment.