mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-12 13:42:08 +08:00
refactor: remove unnecessary async/await from service and proxy functions
This commit is contained in:
@@ -218,7 +218,7 @@ impl EventDrivenProxyManager {
|
||||
Self::enable_system_proxy(state).await;
|
||||
}
|
||||
ProxyEvent::DisableProxy => {
|
||||
Self::disable_system_proxy(state).await;
|
||||
Self::disable_system_proxy(state);
|
||||
}
|
||||
ProxyEvent::SwitchToPac => {
|
||||
Self::switch_proxy_mode(state, true).await;
|
||||
@@ -307,7 +307,7 @@ impl EventDrivenProxyManager {
|
||||
|
||||
if !current.enable || current.url != expected.url {
|
||||
log::info!(target: "app", "PAC代理设置异常,正在恢复...");
|
||||
Self::restore_pac_proxy(&expected.url).await;
|
||||
Self::restore_pac_proxy(&expected.url);
|
||||
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
let restored = Self::get_auto_proxy_with_timeout().await;
|
||||
@@ -329,7 +329,7 @@ impl EventDrivenProxyManager {
|
||||
|
||||
if !current.enable || current.host != expected.host || current.port != expected.port {
|
||||
log::info!(target: "app", "系统代理设置异常,正在恢复...");
|
||||
Self::restore_sys_proxy(&expected).await;
|
||||
Self::restore_sys_proxy(&expected);
|
||||
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
let restored = Self::get_sys_proxy_with_timeout().await;
|
||||
@@ -350,16 +350,16 @@ impl EventDrivenProxyManager {
|
||||
|
||||
if pac_enabled {
|
||||
let expected = Self::get_expected_pac_config();
|
||||
Self::restore_pac_proxy(&expected.url).await;
|
||||
Self::restore_pac_proxy(&expected.url);
|
||||
} else {
|
||||
let expected = Self::get_expected_sys_proxy();
|
||||
Self::restore_sys_proxy(&expected).await;
|
||||
Self::restore_sys_proxy(&expected);
|
||||
}
|
||||
|
||||
Self::check_and_restore_proxy(state).await;
|
||||
}
|
||||
|
||||
async fn disable_system_proxy(_state: &Arc<RwLock<ProxyState>>) {
|
||||
fn disable_system_proxy(_state: &Arc<RwLock<ProxyState>>) {
|
||||
log::info!(target: "app", "禁用系统代理");
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
@@ -380,13 +380,13 @@ impl EventDrivenProxyManager {
|
||||
logging_error!(Type::System, true, disabled_sys.set_system_proxy());
|
||||
|
||||
let expected = Self::get_expected_pac_config();
|
||||
Self::restore_pac_proxy(&expected.url).await;
|
||||
Self::restore_pac_proxy(&expected.url);
|
||||
} else {
|
||||
let disabled_auto = Autoproxy::default();
|
||||
logging_error!(Type::System, true, disabled_auto.set_auto_proxy());
|
||||
|
||||
let expected = Self::get_expected_sys_proxy();
|
||||
Self::restore_sys_proxy(&expected).await;
|
||||
Self::restore_sys_proxy(&expected);
|
||||
}
|
||||
|
||||
Self::update_state_timestamp(state, |s| s.pac_enabled = to_pac);
|
||||
@@ -506,7 +506,7 @@ impl EventDrivenProxyManager {
|
||||
}
|
||||
}
|
||||
|
||||
async fn restore_pac_proxy(expected_url: &str) {
|
||||
fn restore_pac_proxy(expected_url: &str) {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
let new_autoproxy = Autoproxy {
|
||||
@@ -522,7 +522,7 @@ impl EventDrivenProxyManager {
|
||||
}
|
||||
}
|
||||
|
||||
async fn restore_sys_proxy(expected: &Sysproxy) {
|
||||
fn restore_sys_proxy(expected: &Sysproxy) {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
logging_error!(Type::System, true, expected.set_system_proxy());
|
||||
|
||||
Reference in New Issue
Block a user