@@ -112,10 +112,7 @@ public class ConfigHandler
112112
113113 config . ConstItem ??= new ConstItem ( ) ;
114114
115- if ( config . SimpleDNSItem == null )
116- {
117- InitBuiltinSimpleDNS ( config ) ;
118- }
115+ config . SimpleDNSItem ??= InitBuiltinSimpleDNS ( ) ;
119116
120117 config . SpeedTestItem ??= new ( ) ;
121118 if ( config . SpeedTestItem . SpeedTestTimeout < 10 )
@@ -2212,9 +2209,9 @@ public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
22122209
22132210 #region Simple DNS
22142211
2215- public static int InitBuiltinSimpleDNS ( Config config )
2212+ public static SimpleDNSItem InitBuiltinSimpleDNS ( )
22162213 {
2217- config . SimpleDNSItem = new SimpleDNSItem ( )
2214+ return new SimpleDNSItem ( )
22182215 {
22192216 UseSystemHosts = false ,
22202217 AddCommonHosts = true ,
@@ -2225,7 +2222,6 @@ public static int InitBuiltinSimpleDNS(Config config)
22252222 SingboxOutboundsResolveDNS = Global . DomainDirectDNSAddress . FirstOrDefault ( ) ,
22262223 SingboxFinalResolveDNS = Global . DomainPureIPDNSAddress . FirstOrDefault ( )
22272224 } ;
2228- return 0 ;
22292225 }
22302226
22312227 public static async Task < SimpleDNSItem > GetExternalSimpleDNSItem ( string url )
@@ -2263,9 +2259,8 @@ public static async Task<bool> ApplyRegionalPreset(Config config, EPresetType ty
22632259 await SQLiteHelper . Instance . DeleteAllAsync < DNSItem > ( ) ;
22642260 await InitBuiltinDNS ( config ) ;
22652261
2266- InitBuiltinSimpleDNS ( config ) ;
2267-
2268- return true ;
2262+ config . SimpleDNSItem = InitBuiltinSimpleDNS ( ) ;
2263+ break ;
22692264
22702265 case EPresetType . Russia :
22712266 config . ConstItem . GeoSourceUrl = Global . GeoFilesSources [ 1 ] ;
@@ -2275,9 +2270,8 @@ public static async Task<bool> ApplyRegionalPreset(Config config, EPresetType ty
22752270 await SaveDNSItems ( config , await GetExternalDNSItem ( ECoreType . Xray , Global . DNSTemplateSources [ 1 ] + "v2ray.json" ) ) ;
22762271 await SaveDNSItems ( config , await GetExternalDNSItem ( ECoreType . sing_box , Global . DNSTemplateSources [ 1 ] + "sing_box.json" ) ) ;
22772272
2278- config . SimpleDNSItem = await GetExternalSimpleDNSItem ( Global . DNSTemplateSources [ 1 ] + "simple_dns.json" ) ;
2279-
2280- return true ;
2273+ config . SimpleDNSItem = await GetExternalSimpleDNSItem ( Global . DNSTemplateSources [ 1 ] + "simple_dns.json" ) ?? InitBuiltinSimpleDNS ( ) ;
2274+ break ;
22812275
22822276 case EPresetType . Iran :
22832277 config . ConstItem . GeoSourceUrl = Global . GeoFilesSources [ 2 ] ;
@@ -2287,12 +2281,11 @@ public static async Task<bool> ApplyRegionalPreset(Config config, EPresetType ty
22872281 await SaveDNSItems ( config , await GetExternalDNSItem ( ECoreType . Xray , Global . DNSTemplateSources [ 2 ] + "v2ray.json" ) ) ;
22882282 await SaveDNSItems ( config , await GetExternalDNSItem ( ECoreType . sing_box , Global . DNSTemplateSources [ 2 ] + "sing_box.json" ) ) ;
22892283
2290- config . SimpleDNSItem = await GetExternalSimpleDNSItem ( Global . DNSTemplateSources [ 2 ] + "simple_dns.json" ) ;
2291-
2292- return true ;
2284+ config . SimpleDNSItem = await GetExternalSimpleDNSItem ( Global . DNSTemplateSources [ 2 ] + "simple_dns.json" ) ?? InitBuiltinSimpleDNS ( ) ;
2285+ break ;
22932286 }
22942287
2295- return false ;
2288+ return true ;
22962289 }
22972290
22982291 #endregion Regional Presets
0 commit comments