From df79ed3efb5f9676b4191b49d1455af950544461 Mon Sep 17 00:00:00 2001
From: Tunglies <77394545+Tunglies@users.noreply.github.com>
Date: Mon, 21 Sep 2026 14:54:06 +0800
Subject: [PATCH] Revert "feat(dns): protect provider DNS from unconfirmed
overrides (#7902)"
This reverts commit 35a2b6c75c5eeed98617fbf8f8779589680f281d.
Closes #7994
Closes #7993
---
Changelog.md | 2 +-
src-tauri/src/cmd/clash.rs | 13 --
src-tauri/src/cmd/profile.rs | 5 -
src-tauri/src/cmd/save_profile.rs | 3 +-
src-tauri/src/config/config.rs | 4 +-
src-tauri/src/config/dns.rs | 211 ------------------
src-tauri/src/config/mod.rs | 1 -
src-tauri/src/config/runtime.rs | 1 -
src-tauri/src/config/verge.rs | 4 -
src-tauri/src/core/manager/config.rs | 1 -
src-tauri/src/enhance/mod.rs | 19 +-
src-tauri/src/feat/backup.rs | 3 +-
src-tauri/src/feat/dns.rs | 63 ------
src-tauri/src/feat/mod.rs | 2 -
src-tauri/src/feat/profile.rs | 9 +-
src-tauri/src/lib.rs | 2 -
src/components/setting/mods/dns-viewer.tsx | 6 +-
src/components/setting/setting-clash.tsx | 71 ++----
src/locales/ar/settings.json | 7 -
src/locales/de/settings.json | 7 -
src/locales/en/settings.json | 7 -
src/locales/es/settings.json | 7 -
src/locales/fa/settings.json | 7 -
src/locales/id/settings.json | 7 -
src/locales/jp/settings.json | 7 -
src/locales/ko/settings.json | 7 -
src/locales/ru/settings.json | 7 -
src/locales/tr/settings.json | 7 -
src/locales/tt/settings.json | 7 -
src/locales/zh/settings.json | 7 -
src/locales/zhtw/settings.json | 7 -
.../_layout/hooks/use-layout-events.test.ts | 55 -----
src/pages/_layout/hooks/use-layout-events.ts | 3 +-
.../_layout/utils/notification-handlers.ts | 16 +-
src/services/cmds.ts | 10 -
src/types/generated/i18n-keys.ts | 5 -
src/types/generated/i18n-resources.ts | 7 -
37 files changed, 37 insertions(+), 570 deletions(-)
delete mode 100644 src-tauri/src/config/dns.rs
delete mode 100644 src-tauri/src/feat/dns.rs
delete mode 100644 src/pages/_layout/hooks/use-layout-events.test.ts
diff --git a/Changelog.md b/Changelog.md
index 49b83c155..41de3940e 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -3,7 +3,7 @@
🐞 修复问题
-- 修复 DNS 覆写:空内容报错、初始值覆盖已有设置、已填写字段残留原配置、空字段在高级编辑器中缺失
+- 回退 2.5.4 引入的 DNS 覆写保护,修复重启后开关自动关闭
diff --git a/src-tauri/src/cmd/clash.rs b/src-tauri/src/cmd/clash.rs
index c15f06abd..6bba2b789 100644
--- a/src-tauri/src/cmd/clash.rs
+++ b/src-tauri/src/cmd/clash.rs
@@ -127,18 +127,6 @@ pub async fn save_dns_config(dns_config: Mapping) -> CmdResult {
Ok(())
}
-#[tauri::command]
-pub fn take_dns_override_notice() -> bool {
- crate::config::dns::take_dns_override_notice()
-}
-
-#[tauri::command]
-pub async fn set_dns_override(enabled: bool, confirmation: Option) -> CmdResult {
- feat::set_dns_override(enabled, confirmation)
- .await
- .map_err(|error| proxy_aware_coded_error(&error, "DNS_OVERRIDE_UPDATE_FAILED"))
-}
-
#[tauri::command]
pub async fn apply_dns_config(apply: bool) -> CmdResult {
if apply {
@@ -181,7 +169,6 @@ pub async fn apply_dns_config(apply: bool) -> CmdResult {
logging!(info, Type::Config, "Config regenerated successfully");
}
- logging_error!(Type::Config, Config::sync_dns_override().await);
handle::Handle::refresh_clash();
Ok(())
}
diff --git a/src-tauri/src/cmd/profile.rs b/src-tauri/src/cmd/profile.rs
index 2d790e7a3..dcdd4b12b 100644
--- a/src-tauri/src/cmd/profile.rs
+++ b/src-tauri/src/cmd/profile.rs
@@ -180,10 +180,6 @@ pub async fn delete_profile(index: String) -> CmdResult {
drop(config_update_guard);
drop(profile_write_guard);
- if should_update {
- logging_error!(Type::Config, Config::sync_dns_override().await);
- }
-
if let Err(e) = Tray::global().update_tooltip().await {
logging!(warn, Type::Cmd, "异步更新托盘提示失败: {e:#}");
}
@@ -253,7 +249,6 @@ async fn handle_success(current_value: Option<&String>) -> CmdResult {
- logging_error!(Type::Config, Config::sync_dns_override().await);
handle::Handle::refresh_clash();
Ok(ValidationOutcome::Valid)
}
diff --git a/src-tauri/src/config/config.rs b/src-tauri/src/config/config.rs
index 4abc64ad2..6e79af60d 100644
--- a/src-tauri/src/config/config.rs
+++ b/src-tauri/src/config/config.rs
@@ -109,7 +109,6 @@ impl Config {
}
Self::runtime().await.apply();
- logging_error!(Type::Config, Self::sync_dns_override().await);
Ok(())
}
@@ -226,7 +225,7 @@ impl Config {
}
pub(crate) async fn generate_with_profiles(profiles: &IProfiles) -> Result<()> {
- let (mut config, exists_keys, logs, dns_override) = enhance::enhance(profiles).await?;
+ let (mut config, exists_keys, logs) = enhance::enhance(profiles).await?;
sanitize_tunnels_proxy(&mut config);
// Apply only to generated core config so the saved choice survives the next launch.
@@ -237,7 +236,6 @@ impl Config {
Self::runtime().await.edit_draft(|d| {
*d = IRuntime {
config: Some(config),
- dns_override: Some(dns_override),
exists_keys,
chain_logs: logs,
}
diff --git a/src-tauri/src/config/dns.rs b/src-tauri/src/config/dns.rs
deleted file mode 100644
index f752f14d9..000000000
--- a/src-tauri/src/config/dns.rs
+++ /dev/null
@@ -1,211 +0,0 @@
-use anyhow::Result;
-use clash_verge_draft::DraftTransaction;
-use serde_yaml_ng::{Mapping, Value};
-use sha2::{Digest as _, Sha256};
-use smartstring::alias::String;
-use std::sync::atomic::{AtomicBool, Ordering};
-
-use super::{Config, IVerge};
-use crate::core::handle::Handle;
-
-static PENDING_DNS_OVERRIDE_NOTICE: AtomicBool = AtomicBool::new(false);
-
-pub(crate) fn take_dns_override_notice() -> bool {
- PENDING_DNS_OVERRIDE_NOTICE.swap(false, Ordering::Relaxed)
-}
-
-const PROVIDER_DNS_FIELDS: [&str; 3] = [
- "proxy-server-nameserver",
- "proxy-server-nameserver-policy",
- "nameserver-policy",
-];
-
-pub(crate) fn dns_override_source(profile_uid: &str, config: &Mapping) -> Result