From 9e3c0809090c36fa89a52485c2b13e300857fb5f Mon Sep 17 00:00:00 2001 From: GyDi Date: Thu, 21 Apr 2022 19:50:22 +0800 Subject: [PATCH] fix: adjust dns config --- src-tauri/src/core/clash.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src-tauri/src/core/clash.rs b/src-tauri/src/core/clash.rs index 4257e42..242ad75 100644 --- a/src-tauri/src/core/clash.rs +++ b/src-tauri/src/core/clash.rs @@ -179,18 +179,17 @@ impl Clash { revise!(config, "tun", new_tun); - // dns config - let dns_val = config.get(&Value::from("dns")); - let mut new_dns = Mapping::new(); - - if dns_val.is_some() && dns_val.as_ref().unwrap().is_mapping() { - new_dns = dns_val.as_ref().unwrap().as_mapping().unwrap().clone(); - } - - // 借鉴cfw的默认配置 - revise!(new_dns, "enable", enable); - if enable { + // dns config + let dns_val = config.get(&Value::from("dns")); + let mut new_dns = Mapping::new(); + + if dns_val.is_some() && dns_val.as_ref().unwrap().is_mapping() { + new_dns = dns_val.as_ref().unwrap().as_mapping().unwrap().clone(); + } + revise!(new_dns, "enable", enable); + + // 借鉴cfw的默认配置 append!(new_dns, "enhanced-mode", "fake-ip"); append!( new_dns, @@ -209,9 +208,10 @@ impl Clash { "www.msftconnecttest.com" ] ); + + revise!(config, "dns", new_dns); } - revise!(config, "dns", new_dns); config }