refactor: simplify sysproxy logic

1. close all proxies directly when reset_proxy
2. init_sysproxy and update_sysproxy combined into one
3. optimize lock usage
4 ptimize the thread loop of guard_sysproxy,
This commit is contained in:
huzibaca
2024-10-03 01:31:37 +08:00
parent 3a3fc986c4
commit 335578dd91
3 changed files with 48 additions and 163 deletions

View File

@@ -175,7 +175,6 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
let mut should_update_clash_config = false;
let mut should_update_launch = false;
let mut should_update_sysproxy = false;
let mut should_update_guard_proxy = false;
let mut should_update_systray_part = false;
let service_mode = patch.enable_service_mode;
@@ -214,11 +213,6 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|| pac_content.is_some()
{
should_update_sysproxy = true;
should_update_guard_proxy = true;
}
if let Some(true) = patch.enable_proxy_guard {
should_update_guard_proxy = true;
}
if language.is_some()
@@ -245,9 +239,6 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
if should_update_sysproxy {
sysopt::Sysopt::global().update_sysproxy()?;
}
if should_update_guard_proxy {
sysopt::Sysopt::global().guard_proxy();
}
if let Some(hotkeys) = patch.hotkeys {
hotkey::Hotkey::global().update(hotkeys)?;