fix: make port change set to system proxy immediately (#256)

This commit is contained in:
Lai Zn 2024-01-18 09:37:46 +08:00 committed by GitHub
parent d11c322e1f
commit b6dd6f3a94
2 changed files with 8 additions and 1 deletions

View File

@ -123,6 +123,12 @@ impl Sysopt {
sysproxy.enable = enable; sysproxy.enable = enable;
sysproxy.bypass = bypass.unwrap_or(DEFAULT_BYPASS.into()); sysproxy.bypass = bypass.unwrap_or(DEFAULT_BYPASS.into());
let port = Config::verge()
.latest()
.verge_mixed_port
.unwrap_or(Config::clash().data().get_mixed_port());
sysproxy.port = port;
if registry_mode { if registry_mode {
#[cfg(windows)] #[cfg(windows)]
sysproxy.set_system_proxy_with_registry()?; sysproxy.set_system_proxy_with_registry()?;

View File

@ -225,6 +225,7 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
let system_proxy = patch.enable_system_proxy; let system_proxy = patch.enable_system_proxy;
let proxy_bypass = patch.system_proxy_bypass; let proxy_bypass = patch.system_proxy_bypass;
let language = patch.language; let language = patch.language;
let port = patch.verge_mixed_port;
match { match {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
@ -249,7 +250,7 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
if auto_launch.is_some() { if auto_launch.is_some() {
sysopt::Sysopt::global().update_launch()?; sysopt::Sysopt::global().update_launch()?;
} }
if system_proxy.is_some() || proxy_bypass.is_some() { if system_proxy.is_some() || proxy_bypass.is_some() || port.is_some() {
sysopt::Sysopt::global().update_sysproxy()?; sysopt::Sysopt::global().update_sysproxy()?;
sysopt::Sysopt::global().guard_proxy(); sysopt::Sysopt::global().guard_proxy();
} }