This commit is contained in:
asxalex 2024-07-05 23:27:49 +08:00
parent 7bd99d346a
commit 4a2bcb89cc

View File

@ -51,7 +51,8 @@ impl Iface {
let ip = ip_to_string(&ip);
let netbit = ip_to_string(&net_bit_len_to_mask(netbit));
let res = Command::new("netsh")
let mut cmd = Command::new("netsh");
let command = cmd
.arg("interface")
.arg("ip")
.arg("set")
@ -59,11 +60,13 @@ impl Iface {
.arg(&format!("name=\"{}\"", self.name))
.arg("source=static")
.arg(&format!("addr={}", ip))
.arg(&format!("mask={}", netbit))
.output();
.arg(&format!("mask={}", netbit));
let res = command.output();
match res {
Ok(_) => {
debug!("netsh ok");
Ok(r) => {
debug!("netsh ok: {:?}", r);
}
Err(e) => {
error!("failed to run netsh: {}", e.to_string());