mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 19:56:50 +08:00
chore: update
This commit is contained in:
parent
a626f2ce29
commit
6b902a7ad8
|
@ -80,7 +80,7 @@ impl Sysopt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// init the sysproxy
|
/// init the sysproxy
|
||||||
pub fn update_sysproxy(&self) -> Result<()> {
|
pub async fn update_sysproxy(&self) -> Result<()> {
|
||||||
let _ = self.update_sysproxy.lock();
|
let _ = self.update_sysproxy.lock();
|
||||||
|
|
||||||
let port = Config::verge()
|
let port = Config::verge()
|
||||||
|
@ -125,7 +125,7 @@ impl Sysopt {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
if !enable {
|
if !enable {
|
||||||
return self.reset_sysproxy();
|
return self.reset_sysproxy().await;
|
||||||
}
|
}
|
||||||
use crate::core::handle::Handle;
|
use crate::core::handle::Handle;
|
||||||
use crate::utils::dirs;
|
use crate::utils::dirs;
|
||||||
|
@ -143,26 +143,22 @@ impl Sysopt {
|
||||||
let shell = app_handle.shell();
|
let shell = app_handle.shell();
|
||||||
let output = if pac {
|
let output = if pac {
|
||||||
let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port);
|
let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port);
|
||||||
let output = tauri::async_runtime::block_on(async move {
|
let output = shell
|
||||||
shell
|
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["opac", address.as_str()])
|
.args(["opac", address.as_str()])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap();
|
||||||
});
|
|
||||||
output
|
output
|
||||||
} else {
|
} else {
|
||||||
let address = format!("{}:{}", "127.0.0.1", port);
|
let address = format!("{}:{}", "127.0.0.1", port);
|
||||||
let bypass = get_bypass();
|
let bypass = get_bypass();
|
||||||
let output = tauri::async_runtime::block_on(async move {
|
let output = shell
|
||||||
shell
|
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["global", address.as_str(), bypass.as_ref()])
|
.args(["global", address.as_str(), bypass.as_ref()])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap();
|
||||||
});
|
|
||||||
output
|
output
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,7 +171,7 @@ impl Sysopt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// reset the sysproxy
|
/// reset the sysproxy
|
||||||
pub fn reset_sysproxy(&self) -> Result<()> {
|
pub async fn reset_sysproxy(&self) -> Result<()> {
|
||||||
let _ = self.reset_sysproxy.lock();
|
let _ = self.reset_sysproxy.lock();
|
||||||
//直接关闭所有代理
|
//直接关闭所有代理
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
@ -205,14 +201,12 @@ impl Sysopt {
|
||||||
}
|
}
|
||||||
|
|
||||||
let shell = app_handle.shell();
|
let shell = app_handle.shell();
|
||||||
let output = tauri::async_runtime::block_on(async move {
|
let output = shell
|
||||||
shell
|
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["set", "1"])
|
.args(["set", "1"])
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap();
|
||||||
});
|
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
bail!("sysproxy exe run failed");
|
bail!("sysproxy exe run failed");
|
||||||
|
|
|
@ -237,7 +237,7 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_update_sysproxy {
|
if should_update_sysproxy {
|
||||||
sysopt::Sysopt::global().update_sysproxy()?;
|
sysopt::Sysopt::global().update_sysproxy().await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(hotkeys) = patch.hotkeys {
|
if let Some(hotkeys) = patch.hotkeys {
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub async fn resolve_setup(app: &mut App) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log_err!(sysopt::Sysopt::global().init_launch());
|
log_err!(sysopt::Sysopt::global().init_launch());
|
||||||
log_err!(sysopt::Sysopt::global().update_sysproxy());
|
log_err!(sysopt::Sysopt::global().update_sysproxy().await);
|
||||||
log_err!(sysopt::Sysopt::global().init_guard_sysproxy());
|
log_err!(sysopt::Sysopt::global().init_guard_sysproxy());
|
||||||
|
|
||||||
log_err!(handle::Handle::update_systray_part());
|
log_err!(handle::Handle::update_systray_part());
|
||||||
|
@ -104,8 +104,8 @@ pub async fn resolve_setup(app: &mut App) {
|
||||||
|
|
||||||
/// reset system proxy
|
/// reset system proxy
|
||||||
pub fn resolve_reset() {
|
pub fn resolve_reset() {
|
||||||
log_err!(sysopt::Sysopt::global().reset_sysproxy());
|
|
||||||
tauri::async_runtime::block_on(async move {
|
tauri::async_runtime::block_on(async move {
|
||||||
|
log_err!(sysopt::Sysopt::global().reset_sysproxy().await);
|
||||||
log_err!(CoreManager::global().stop_core().await);
|
log_err!(CoreManager::global().stop_core().await);
|
||||||
log_err!(service::unset_dns_by_service().await);
|
log_err!(service::unset_dns_by_service().await);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user