diff --git a/.cargo/config.toml b/.cargo/config.toml index 46cf537..bf99b02 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,3 +3,6 @@ linker = "x86_64-linux-musl-gcc" [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" + +[target.x86_64-pc-windows-gnu] +linker = "x86_64-w64-mingw32-gcc" diff --git a/Makefile b/Makefile index e937f3a..228a941 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ linux-tun: RUSTFLAGS="-L ." cargo build --features "tun" --release win: - cargo build --release + cargo build --release --target x86_64-pc-windows-gnu pb: cargo run --bin build_pb diff --git a/src/network/tun_win.rs b/src/network/tun_win.rs index 742324d..e39af72 100644 --- a/src/network/tun_win.rs +++ b/src/network/tun_win.rs @@ -91,6 +91,28 @@ impl Iface { error!("failed to run netsh: {}", e.to_string()); } } + + let mut cmd = Command::new("netsh"); + let command = cmd + .creation_flags(0x08000000) + .arg("interface") + .arg("ipv4") + .arg("set") + .arg("subinterface") + .arg(&format!("\"{}\"", self.name)) + .arg(format!("mtu={}", device_config.mtu)) + .arg("store=persistent"); + + let res = command.output(); + + match res { + Ok(r) => { + debug!("netsh2 ok: [{:?}]", String::from_utf8_lossy(&r.stdout)); + } + Err(e) => { + error!("failed to run netsh2: {}", e.to_string()); + } + } } }