fix: patch verge config

This commit is contained in:
GyDi 2022-02-19 17:32:23 +08:00
parent 457655b416
commit 10b55c043c
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -206,9 +206,12 @@ impl Verge {
// should update system proxy // should update system proxy
if patch.enable_system_proxy.is_some() { if patch.enable_system_proxy.is_some() {
let enable = patch.enable_system_proxy.unwrap(); let enable = patch.enable_system_proxy.unwrap();
if let Some(mut sysproxy) = self.cur_sysproxy.take() { if let Some(mut sysproxy) = self.cur_sysproxy.take() {
sysproxy.enable = enable; sysproxy.enable = enable;
if sysproxy.set_sys().is_err() { if sysproxy.set_sys().is_err() {
self.cur_sysproxy = Some(sysproxy);
log::error!("failed to set system proxy"); log::error!("failed to set system proxy");
return Err("failed to set system proxy".into()); return Err("failed to set system proxy".into());
} }
@ -217,10 +220,26 @@ impl Verge {
self.config.enable_system_proxy = Some(enable); self.config.enable_system_proxy = Some(enable);
} }
// todo
// should update system proxy too // should update system proxy too
if patch.system_proxy_bypass.is_some() { if patch.system_proxy_bypass.is_some() {
self.config.system_proxy_bypass = patch.system_proxy_bypass; let bypass = patch.system_proxy_bypass.unwrap();
if let Some(mut sysproxy) = self.cur_sysproxy.take() {
if sysproxy.enable {
sysproxy.bypass = bypass.clone();
if sysproxy.set_sys().is_err() {
self.cur_sysproxy = Some(sysproxy);
log::error!("failed to set system proxy");
return Err("failed to set system proxy".into());
}
}
self.cur_sysproxy = Some(sysproxy);
}
self.config.system_proxy_bypass = Some(bypass);
} }
self.config.save_file() self.config.save_file()