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