mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 03:32:36 +08:00
fix: Try to fix #577 again
This commit is contained in:
parent
812dbfd836
commit
462fb05ea8
|
@ -105,24 +105,6 @@ impl CoreManager {
|
||||||
sleep(Duration::from_millis(500)).await;
|
sleep(Duration::from_millis(500)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
let enable_tun = Config::verge().latest().enable_tun_mode.clone();
|
|
||||||
let enable_tun = enable_tun.unwrap_or(false);
|
|
||||||
log::debug!(target: "app", "try to set system dns");
|
|
||||||
if enable_tun {
|
|
||||||
let resource_dir = dirs::app_resources_dir()?;
|
|
||||||
let script = resource_dir.join("set_dns.sh");
|
|
||||||
let script = script.to_string_lossy();
|
|
||||||
match (|| Command::new("bash").args([script]).output())() {
|
|
||||||
Ok(_) => return Ok(()),
|
|
||||||
Err(err) => {
|
|
||||||
log::error!(target: "app", "{err}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use super::win_service;
|
use super::win_service;
|
||||||
|
@ -264,23 +246,6 @@ impl CoreManager {
|
||||||
});
|
});
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
let enable_tun = Config::verge().latest().enable_tun_mode.clone();
|
|
||||||
let enable_tun = enable_tun.unwrap_or(false);
|
|
||||||
log::debug!(target: "app", "try to unset system dns");
|
|
||||||
if enable_tun {
|
|
||||||
let resource_dir = dirs::app_resources_dir()?;
|
|
||||||
let script = resource_dir.join("unset_dns.sh");
|
|
||||||
let script = script.to_string_lossy();
|
|
||||||
match (|| Command::new("bash").args([script]).output())() {
|
|
||||||
Ok(_) => return Ok(()),
|
|
||||||
Err(err) => {
|
|
||||||
log::error!(target: "app", "{err}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut sidecar = self.sidecar.lock();
|
let mut sidecar = self.sidecar.lock();
|
||||||
if let Some(child) = sidecar.take() {
|
if let Some(child) = sidecar.take() {
|
||||||
|
|
|
@ -34,8 +34,38 @@ pub fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
|
||||||
revise!(config, "tun", tun_val);
|
revise!(config, "tun", tun_val);
|
||||||
|
|
||||||
if enable {
|
if enable {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use crate::utils::dirs;
|
||||||
|
use tauri::api::process::Command;
|
||||||
|
log::info!(target: "app", "try to set system dns");
|
||||||
|
let resource_dir = dirs::app_resources_dir().unwrap();
|
||||||
|
let script = resource_dir.join("set_dns.sh");
|
||||||
|
let script = script.to_string_lossy();
|
||||||
|
match Command::new("bash").args([script]).output() {
|
||||||
|
Ok(_) => log::info!(target: "app", "set system dns successfully"),
|
||||||
|
Err(err) => {
|
||||||
|
log::error!(target: "app", "set system dns failed: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
use_dns_for_tun(config)
|
use_dns_for_tun(config)
|
||||||
} else {
|
} else {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use crate::utils::dirs;
|
||||||
|
use tauri::api::process::Command;
|
||||||
|
log::info!(target: "app", "try to unset system dns");
|
||||||
|
let resource_dir = dirs::app_resources_dir().unwrap();
|
||||||
|
let script = resource_dir.join("unset_dns.sh");
|
||||||
|
let script = script.to_string_lossy();
|
||||||
|
match Command::new("bash").args([script]).output() {
|
||||||
|
Ok(_) => log::info!(target: "app", "unset system dns successfully"),
|
||||||
|
Err(err) => {
|
||||||
|
log::error!(target: "app", "unset system dns failed: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user