mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: Try to fix #577
This commit is contained in:
@@ -111,8 +111,10 @@ impl CoreManager {
|
||||
let enable_tun = enable_tun.unwrap_or(false);
|
||||
log::debug!(target: "app", "try to set system dns");
|
||||
if enable_tun {
|
||||
let script = include_str!("./script/set_dns.sh");
|
||||
match (|| async { Command::new("bash").args([script]).output() })().await {
|
||||
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}");
|
||||
@@ -262,14 +264,15 @@ impl CoreManager {
|
||||
});
|
||||
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 script = include_str!("./script/unset_dns.sh");
|
||||
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) => {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
nic=$(route -n get default | grep "interface" | awk '{print $2}')
|
||||
|
||||
hardware_port=$(networksetup -listallhardwareports | awk -v dev="$nic" '/Hardware Port/{port=$3} /Device:/{if ($2 == dev) {print port; exit}}')
|
||||
|
||||
networksetup -setdnsservers $hardware_port 223.5.5.5
|
||||
@@ -1,5 +0,0 @@
|
||||
nic=$(route -n get default | grep "interface" | awk '{print $2}')
|
||||
|
||||
hardware_port=$(networksetup -listallhardwareports | awk -v dev="$nic" '/Hardware Port/{port=$3} /Device:/{if ($2 == dev) {print port; exit}}')
|
||||
|
||||
networksetup -setdnsservers $hardware_port Empty
|
||||
Reference in New Issue
Block a user