feat(dns): protect provider DNS from unconfirmed overrides (#7902)

Fixes #7292
This commit is contained in:
wonfen
2026-09-09 23:19:56 +08:00
committed by GitHub
parent b06a966a4b
commit 35a2b6c75c
36 changed files with 565 additions and 35 deletions
+13
View File
@@ -127,6 +127,18 @@ 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<String>) -> CmdResult<feat::DnsOverrideOutcome> {
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 {
@@ -169,6 +181,7 @@ 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(())
}
+5
View File
@@ -180,6 +180,10 @@ 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:#}");
}
@@ -249,6 +253,7 @@ async fn handle_success(current_value: Option<&String>) -> CmdResult<ValidationO
handle::Handle::notify_profile_changed(current);
}
logging_error!(Type::Config, Config::sync_dns_override().await);
Ok(ValidationOutcome::Valid)
}
+2 -1
View File
@@ -10,7 +10,7 @@ use crate::{
module::auto_backup::{AutoBackupManager, AutoBackupTrigger},
utils::dirs,
};
use clash_verge_logging::{Type, logging};
use clash_verge_logging::{Type, logging, logging_error};
use smartstring::alias::String;
use tokio::fs;
@@ -162,6 +162,7 @@ async fn handle_saved_profile_file(
);
match CoreManager::global().update_config_forced().await {
Ok(outcome) if outcome.is_valid() => {
logging_error!(Type::Config, Config::sync_dns_override().await);
handle::Handle::refresh_clash();
Ok(ValidationOutcome::Valid)
}