diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 2e11d90f..cf53c3e0 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -1078,6 +1078,10 @@ namespace v2rayN.Handler { return -1; } + if (routingItem.rules == null) + { + routingItem.rules = new List(); + } if (blReplace) { routingItem.rules.Clear(); @@ -1189,35 +1193,44 @@ namespace v2rayN.Handler if (config.routings.Count(it => it.locked != true) <= 0) { //Global - var item1 = new RoutingItem(); - item1.remarks = "全局(Global)"; - item1.url = string.Empty; - item1.rules = new List(); - string result1 = Utils.GetEmbedText(Global.CustomRoutingFileName + "global"); - AddBatchRoutingRules(ref item1, result1); + var item1 = new RoutingItem() + { + remarks = "全局(Global)", + url = string.Empty, + }; + AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "global")); config.routings.Add(item1); //Bypass the mainland - var item2 = new RoutingItem(); - item2.remarks = "绕过大陆(Whitelist)"; - item2.url = string.Empty; - item2.rules = new List(); - string result2 = Utils.GetEmbedText(Global.CustomRoutingFileName + "white"); - AddBatchRoutingRules(ref item2, result2); + var item2 = new RoutingItem() + { + remarks = "绕过大陆(Whitelist)", + url = string.Empty, + }; + AddBatchRoutingRules(ref item2, Utils.GetEmbedText(Global.CustomRoutingFileName + "white")); config.routings.Add(item2); + //Blacklist + var item3 = new RoutingItem() + { + remarks = "黑名单(Blacklist)", + url = string.Empty, + }; + AddBatchRoutingRules(ref item3, Utils.GetEmbedText(Global.CustomRoutingFileName + "black")); + config.routings.Add(item3); + config.routingIndex = 0; } if (GetLockedRoutingItem(ref config) == null) { - var item1 = new RoutingItem(); - item1.remarks = "locked"; - item1.url = string.Empty; - item1.rules = new List(); - item1.locked = true; - string result1 = Utils.GetEmbedText(Global.CustomRoutingFileName + "locked"); - AddBatchRoutingRules(ref item1, result1); + var item1 = new RoutingItem() + { + remarks = "locked", + url = string.Empty, + locked = true, + }; + AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "locked")); config.routings.Add(item1); } diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index fcfcea40..e0e54269 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -293,6 +293,12 @@ namespace v2rayN.Handler { AllowAutoRedirect = false }; + if (httpProxyTest() > 0) + { + int httpPort = _config.GetLocalPort(Global.InboundHttp); + WebProxy webProxy = new WebProxy(Global.Loopback, httpPort); + webRequestHandler.Proxy = webProxy; + } HttpClient httpClient = new HttpClient(webRequestHandler); string url; diff --git a/v2rayN/v2rayN/Sample/custom_routing_black b/v2rayN/v2rayN/Sample/custom_routing_black new file mode 100644 index 00000000..9005c944 --- /dev/null +++ b/v2rayN/v2rayN/Sample/custom_routing_black @@ -0,0 +1,29 @@ +[ + { + "outboundTag": "direct", + "protocol": [ + "bittorrent" + ] + }, + { + "outboundTag": "block", + "domain": [ + "geosite:category-ads-all" + ] + }, + { + "outboundTag": "proxy", + "ip": [ + "geoip:telegram" + ], + "domain": [ + "geosite:gfw", + "geosite:greatfire", + "geosite:tld-!cn" + ] + }, + { + "port": "0-65535", + "outboundTag": "direct" + } +] \ No newline at end of file diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index ef32ec53..98fc93a2 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -402,6 +402,7 @@ +