Fixed DNS bug with region switch

pull/7733/head 7.13.8
2dust 2025-08-10 21:08:49 +08:00
parent c9989108bd
commit dffc6d9a9b
1 changed files with 10 additions and 17 deletions

View File

@ -112,10 +112,7 @@ public class ConfigHandler
config.ConstItem ??= new ConstItem(); config.ConstItem ??= new ConstItem();
if (config.SimpleDNSItem == null) config.SimpleDNSItem ??= InitBuiltinSimpleDNS();
{
InitBuiltinSimpleDNS(config);
}
config.SpeedTestItem ??= new(); config.SpeedTestItem ??= new();
if (config.SpeedTestItem.SpeedTestTimeout < 10) if (config.SpeedTestItem.SpeedTestTimeout < 10)
@ -2212,9 +2209,9 @@ public class ConfigHandler
#region Simple DNS #region Simple DNS
public static int InitBuiltinSimpleDNS(Config config) public static SimpleDNSItem InitBuiltinSimpleDNS()
{ {
config.SimpleDNSItem = new SimpleDNSItem() return new SimpleDNSItem()
{ {
UseSystemHosts = false, UseSystemHosts = false,
AddCommonHosts = true, AddCommonHosts = true,
@ -2225,7 +2222,6 @@ public class ConfigHandler
SingboxOutboundsResolveDNS = Global.DomainDirectDNSAddress.FirstOrDefault(), SingboxOutboundsResolveDNS = Global.DomainDirectDNSAddress.FirstOrDefault(),
SingboxFinalResolveDNS = Global.DomainPureIPDNSAddress.FirstOrDefault() SingboxFinalResolveDNS = Global.DomainPureIPDNSAddress.FirstOrDefault()
}; };
return 0;
} }
public static async Task<SimpleDNSItem> GetExternalSimpleDNSItem(string url) public static async Task<SimpleDNSItem> GetExternalSimpleDNSItem(string url)
@ -2263,9 +2259,8 @@ public class ConfigHandler
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>(); await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
await InitBuiltinDNS(config); await InitBuiltinDNS(config);
InitBuiltinSimpleDNS(config); config.SimpleDNSItem = InitBuiltinSimpleDNS();
break;
return true;
case EPresetType.Russia: case EPresetType.Russia:
config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1]; config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1];
@ -2275,9 +2270,8 @@ public class ConfigHandler
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json"));
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));
config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[1] + "simple_dns.json"); config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[1] + "simple_dns.json") ?? InitBuiltinSimpleDNS();
break;
return true;
case EPresetType.Iran: case EPresetType.Iran:
config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[2]; config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[2];
@ -2287,12 +2281,11 @@ public class ConfigHandler
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json"));
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json"));
config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[2] + "simple_dns.json"); config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[2] + "simple_dns.json") ?? InitBuiltinSimpleDNS();
break;
return true;
} }
return false; return true;
} }
#endregion Regional Presets #endregion Regional Presets