mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-15 19:22:26 +08:00
fix: Try to fix #577
This commit is contained in:
parent
22d8b73625
commit
ac5fb1948a
|
@ -370,6 +370,16 @@ const resolveUninstall = () =>
|
|||
file: "uninstall-service.exe",
|
||||
downloadURL: `${SERVICE_URL}/uninstall-service.exe`,
|
||||
});
|
||||
const resolveSetDnsScript = () =>
|
||||
resolveResource({
|
||||
file: "set_dns.sh",
|
||||
downloadURL: `https://github.com/clash-verge-rev/set-dns-script/releases/download/script/set_dns.sh`,
|
||||
});
|
||||
const resolveUnSetDnsScript = () =>
|
||||
resolveResource({
|
||||
file: "unset_dns.sh",
|
||||
downloadURL: `https://github.com/clash-verge-rev/set-dns-script/releases/download/script/unset_dns.sh`,
|
||||
});
|
||||
const resolveMmdb = () =>
|
||||
resolveResource({
|
||||
file: "Country.mmdb",
|
||||
|
@ -409,6 +419,8 @@ const tasks = [
|
|||
{ name: "service", func: resolveService, retry: 5, winOnly: true },
|
||||
{ name: "install", func: resolveInstall, retry: 5, winOnly: true },
|
||||
{ name: "uninstall", func: resolveUninstall, retry: 5, winOnly: true },
|
||||
{ name: "set_dns_script", fun: resolveSetDnsScript, retry: 5 },
|
||||
{ name: "unset_dns_script", fun: resolveUnSetDnsScript, retry: 5 },
|
||||
{ name: "mmdb", func: resolveMmdb, retry: 5 },
|
||||
{ name: "geosite", func: resolveGeosite, retry: 5 },
|
||||
{ name: "geoip", func: resolveGeoIP, retry: 5 },
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user