@@ -1651,7 +1651,9 @@ public static async Task<int> AddSubItem(Config config, string url)
16511651
16521652 var uri = Utils . TryUri ( url ) ;
16531653 if ( uri == null )
1654+ {
16541655 return - 1 ;
1656+ }
16551657 //Do not allow http protocol
16561658 if ( url . StartsWith ( Global . HttpProtocol ) && ! Utils . IsPrivateNetwork ( uri . IdnHost ) )
16571659 {
@@ -2018,11 +2020,15 @@ public static async Task<int> InitExternalRouting(Config config, bool blImportAd
20182020 var downloadHandle = new DownloadService ( ) ;
20192021 var templateContent = await downloadHandle . TryDownloadString ( config . ConstItem . RouteRulesTemplateSourceUrl , true , "" ) ;
20202022 if ( templateContent . IsNullOrEmpty ( ) )
2023+ {
20212024 return await InitBuiltinRouting ( config , blImportAdvancedRules ) ; // fallback
2025+ }
20222026
20232027 var template = JsonUtils . Deserialize < RoutingTemplate > ( templateContent ) ;
20242028 if ( template == null )
2029+ {
20252030 return await InitBuiltinRouting ( config , blImportAdvancedRules ) ; // fallback
2031+ }
20262032
20272033 var items = await AppManager . Instance . RoutingItems ( ) ;
20282034 var maxSort = items . Count ;
@@ -2035,14 +2041,18 @@ public static async Task<int> InitExternalRouting(Config config, bool blImportAd
20352041 var item = template . RoutingItems [ i ] ;
20362042
20372043 if ( item . Url . IsNullOrEmpty ( ) && item . RuleSet . IsNullOrEmpty ( ) )
2044+ {
20382045 continue ;
2046+ }
20392047
20402048 var ruleSetsString = ! item . RuleSet . IsNullOrEmpty ( )
20412049 ? item . RuleSet
20422050 : await downloadHandle . TryDownloadString ( item . Url , true , "" ) ;
20432051
20442052 if ( ruleSetsString . IsNullOrEmpty ( ) )
2053+ {
20452054 continue ;
2055+ }
20462056
20472057 item . Remarks = $ "{ template . Version } -{ item . Remarks } ";
20482058 item . Enabled = true ;
@@ -2238,17 +2248,25 @@ public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
22382248 var downloadHandle = new DownloadService ( ) ;
22392249 var templateContent = await downloadHandle . TryDownloadString ( url , true , "" ) ;
22402250 if ( templateContent . IsNullOrEmpty ( ) )
2251+ {
22412252 return currentItem ;
2253+ }
22422254
22432255 var template = JsonUtils . Deserialize < DNSItem > ( templateContent ) ;
22442256 if ( template == null )
2257+ {
22452258 return currentItem ;
2259+ }
22462260
22472261 if ( ! template . NormalDNS . IsNullOrEmpty ( ) )
2262+ {
22482263 template . NormalDNS = await downloadHandle . TryDownloadString ( template . NormalDNS , true , "" ) ;
2264+ }
22492265
22502266 if ( ! template . TunDNS . IsNullOrEmpty ( ) )
2267+ {
22512268 template . TunDNS = await downloadHandle . TryDownloadString ( template . TunDNS , true , "" ) ;
2269+ }
22522270
22532271 template . Id = currentItem . Id ;
22542272 template . Enabled = currentItem . Enabled ;
@@ -2282,10 +2300,16 @@ public static async Task<SimpleDNSItem> GetExternalSimpleDNSItem(string url)
22822300 var downloadHandle = new DownloadService ( ) ;
22832301 var templateContent = await downloadHandle . TryDownloadString ( url , true , "" ) ;
22842302 if ( templateContent . IsNullOrEmpty ( ) )
2303+ {
22852304 return null ;
2305+ }
2306+
22862307 var template = JsonUtils . Deserialize < SimpleDNSItem > ( templateContent ) ;
22872308 if ( template == null )
2309+ {
22882310 return null ;
2311+ }
2312+
22892313 return template ;
22902314 }
22912315
0 commit comments