diff --git a/src-tauri/src/core/clash.rs b/src-tauri/src/core/clash.rs index 4257e42e3d3273f2e2bd5eecbf8438be18521fa8..242ad754020fb7b8511c2288ecc95b5a8773a6ab 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(); - } + if enable { + // dns config + let dns_val = config.get(&Value::from("dns")); + let mut new_dns = Mapping::new(); - // 借鉴cfw的默认é…ç½® - revise!(new_dns, "enable", enable); + 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); - if 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 }