fix(sysproxy): stop turning a missing network service into a hard failure

This commit is contained in:
wonfen
2026-09-02 11:46:37 +08:00
parent 78cc4dc532
commit ef042ddf82
7 changed files with 238 additions and 188 deletions
+10 -3
View File
@@ -1,6 +1,6 @@
use super::CmdResult;
use crate::cmd::StringifyErr as _;
use crate::core::sysopt::Sysopt;
use crate::core::{proxy_control, sysopt::Sysopt};
use clash_verge_logging::{Type, logging};
use gethostname::gethostname;
use network_interface::NetworkInterface;
@@ -13,7 +13,11 @@ pub async fn get_sys_proxy() -> CmdResult<Mapping> {
logging!(debug, Type::Network, "异步获取系统代理配置");
Sysopt::global().wait_idle().await;
let sys_proxy = Sysproxy::get_system_proxy().stringify_err()?;
// With no network service there is no proxy configured anywhere, which reads as disabled.
let sys_proxy = match Sysproxy::get_system_proxy() {
Err(error) if proxy_control::is_missing_network_service(&error) => Sysproxy::default(),
other => other.stringify_err()?,
};
let Sysproxy {
ref host,
ref bypass,
@@ -40,7 +44,10 @@ pub async fn get_sys_proxy() -> CmdResult<Mapping> {
#[tauri::command]
pub async fn get_auto_proxy() -> CmdResult<Mapping> {
Sysopt::global().wait_idle().await;
let auto_proxy = Autoproxy::get_auto_proxy().stringify_err()?;
let auto_proxy = match Autoproxy::get_auto_proxy() {
Err(error) if proxy_control::is_missing_network_service(&error) => Autoproxy::default(),
other => other.stringify_err()?,
};
let Autoproxy { ref enable, ref url } = auto_proxy;
let mut map = Mapping::new();