diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 9040d70c..c70d598d 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -2098,18 +2098,38 @@ public class ConfigHandler /// /// Initialize built-in DNS configurations /// Creates default DNS items for V2Ray and sing-box + /// Also checks existing DNS items and disables those with empty NormalDNS /// /// Current configuration /// 0 if successful public static async Task InitBuiltinDNS(Config config) { var items = await AppHandler.Instance.DNSItems(); + + // Check existing DNS items and disable those with empty NormalDNS + var needsUpdate = false; + foreach (var existingItem in items) + { + if (existingItem.NormalDNS.IsNullOrEmpty() && existingItem.Enabled) + { + existingItem.Enabled = false; + needsUpdate = true; + } + } + + // Update items if any changes were made + if (needsUpdate) + { + await SQLiteHelper.Instance.UpdateAllAsync(items); + } + if (items.Count <= 0) { var item = new DNSItem() { Remarks = "V2ray", CoreType = ECoreType.Xray, + Enabled = false, }; await SaveDNSItems(config, item); @@ -2117,6 +2137,7 @@ public class ConfigHandler { Remarks = "sing-box", CoreType = ECoreType.sing_box, + Enabled = false, }; await SaveDNSItems(config, item2); }