mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-03 05:22:09 +08:00
fix: serialize OS state reads with in-progress update_sysproxy
This commit is contained in:
+3
-1
@@ -11,13 +11,15 @@
|
||||
- 修复 macOS 开关代理时可能的卡死
|
||||
- 修复修改定时自动更新后记时未及时刷新
|
||||
- 修复 Linux 关闭 TUN 不立即生效
|
||||
- 修复系统代理关闭序列逻辑(防止快速退出时系统代理关闭状态没有保存)
|
||||
|
||||
### ✨ 新增功能
|
||||
|
||||
- 订阅 QR code 分享
|
||||
- 新增 macOS 托盘速率显示
|
||||
- 快捷键操作通知操作结果
|
||||
- 软件自动更新(后台下载,下次启动自动安装)
|
||||
|
||||
### 🚀 优化改进
|
||||
|
||||
- 优化 macOS 读取系统代理性能
|
||||
- 优化 macOS 读取系统代理性能
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::CmdResult;
|
||||
use crate::cmd::StringifyErr as _;
|
||||
use crate::core::sysopt::Sysopt;
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use gethostname::gethostname;
|
||||
use network_interface::NetworkInterface;
|
||||
@@ -13,6 +14,7 @@ use tauri_plugin_clash_verge_sysinfo;
|
||||
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()?;
|
||||
let Sysproxy {
|
||||
ref host,
|
||||
@@ -40,6 +42,7 @@ 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 Autoproxy { ref enable, ref url } = auto_proxy;
|
||||
|
||||
|
||||
@@ -106,6 +106,14 @@ impl Sysopt {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wait for any in-progress `update_sysproxy` to finish, so that a
|
||||
/// subsequent read of OS-level sysproxy state sees a fully applied
|
||||
/// configuration instead of a partially-applied one (e.g. SOCKS already
|
||||
/// disabled but HTTP still enabled mid-transition).
|
||||
pub async fn wait_idle(&self) {
|
||||
let _ = self.update_lock.lock().await;
|
||||
}
|
||||
|
||||
/// init the sysproxy
|
||||
pub async fn update_sysproxy(&self) -> Result<()> {
|
||||
let _lock = self.update_lock.lock().await;
|
||||
|
||||
@@ -57,10 +57,10 @@ export const useSystemProxyState = () => {
|
||||
while (pendingRef.current !== null) {
|
||||
const target = pendingRef.current
|
||||
pendingRef.current = null
|
||||
await patchVerge({ enable_system_proxy: target })
|
||||
if (!target && verge?.auto_close_connection) {
|
||||
await closeAllConnections().catch(() => {})
|
||||
}
|
||||
await patchVerge({ enable_system_proxy: target })
|
||||
}
|
||||
} finally {
|
||||
busyRef.current = false
|
||||
|
||||
Reference in New Issue
Block a user