use winapi to config ip and route (remove dep on netsh) (#1079)

On some windows machines can not execut netsh.
Also this avoid black cmd window when using gui.
This commit is contained in:
Sijie.Sun
2025-07-05 16:50:09 +08:00
committed by GitHub
parent d0cfc49806
commit a4bb555fac
13 changed files with 1251 additions and 164 deletions
+5 -2
View File
@@ -3,6 +3,8 @@ mod darwin;
#[cfg(any(target_os = "linux"))]
mod netlink;
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "windows")]
mod windows;
mod route;
@@ -10,6 +12,7 @@ mod route;
use std::net::{Ipv4Addr, Ipv6Addr};
use async_trait::async_trait;
use cidr::{Ipv4Inet, Ipv6Inet};
use tokio::process::Command;
use super::error::Error;
@@ -69,10 +72,10 @@ pub trait IfConfiguerTrait: Send + Sync {
async fn set_link_status(&self, _name: &str, _up: bool) -> Result<(), Error> {
Ok(())
}
async fn remove_ip(&self, _name: &str, _ip: Option<Ipv4Addr>) -> Result<(), Error> {
async fn remove_ip(&self, _name: &str, _ip: Option<Ipv4Inet>) -> Result<(), Error> {
Ok(())
}
async fn remove_ipv6(&self, _name: &str, _ip: Option<Ipv6Addr>) -> Result<(), Error> {
async fn remove_ipv6(&self, _name: &str, _ip: Option<Ipv6Inet>) -> Result<(), Error> {
Ok(())
}
async fn wait_interface_show(&self, _name: &str) -> Result<(), Error> {