mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-28 00:42:08 +08:00
fix(sysproxy): stop turning a missing network service into a hard failure
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user