Skip to content

Commit

Permalink
Bump version 0.7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Sep 27, 2024
1 parent d53f6c3 commit 9b8a58c
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 = "wintun-bindings"
version = "0.7.9"
version = "0.7.10"
edition = "2021"
authors = [
"ssrlive",
Expand Down
2 changes: 1 addition & 1 deletion src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl Adapter {
gateway: Option<IpAddr>,
) -> 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<String> = vec![
Expand Down
13 changes: 11 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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.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)
Expand Down

0 comments on commit 9b8a58c

Please sign in to comment.