refactor(gui): refactor gui to use RemoteClient trait and RemoteManagement component (#1489)

* refactor(gui): refactor gui to use RemoteClient trait and RemoteManagement component
* feat(gui): Add network config saving and refactor RemoteManagement
This commit is contained in:
Mg Pig
2025-10-20 22:07:01 +08:00
committed by GitHub
parent 67ac9b00ff
commit eba9504fc2
27 changed files with 1040 additions and 793 deletions
+8 -10
View File
@@ -474,17 +474,16 @@ impl IfConfiguerTrait for NetlinkIfConfiger {
}
async fn remove_ip(&self, name: &str, ip: Option<Ipv4Inet>) -> Result<(), Error> {
if ip.is_none() {
if let Some(ip) = ip {
let prefix_len = Self::get_prefix_len(name, ip.address())?;
Self::remove_one_ip(name, ip.address(), prefix_len)?;
} else {
let addrs = Self::list_addresses(name)?;
for addr in addrs {
if let IpAddr::V4(ipv4) = addr.address() {
Self::remove_one_ip(name, ipv4, addr.network_length())?;
}
}
} else {
let ip = ip.unwrap();
let prefix_len = Self::get_prefix_len(name, ip.address())?;
Self::remove_one_ip(name, ip.address(), prefix_len)?;
}
Ok(())
@@ -520,7 +519,10 @@ impl IfConfiguerTrait for NetlinkIfConfiger {
}
async fn remove_ipv6(&self, name: &str, ip: Option<Ipv6Inet>) -> Result<(), Error> {
if ip.is_none() {
if let Some(ipv6) = ip {
let prefix_len = Self::get_prefix_len_ipv6(name, ipv6.address())?;
Self::remove_one_ipv6(name, ipv6.address(), prefix_len)?;
} else {
let addrs = Self::list_addresses(name)?;
for addr in addrs {
if let IpAddr::V6(ipv6) = addr.address() {
@@ -528,10 +530,6 @@ impl IfConfiguerTrait for NetlinkIfConfiger {
Self::remove_one_ipv6(name, ipv6, prefix_len)?;
}
}
} else {
let ipv6 = ip.unwrap();
let prefix_len = Self::get_prefix_len_ipv6(name, ipv6.address())?;
Self::remove_one_ipv6(name, ipv6.address(), prefix_len)?;
}
Ok(())