add Blacklist rules

pull/1857/head
2dust 2021-10-10 11:04:50 +08:00
parent 058e1aafd1
commit c4070b26ff
4 changed files with 68 additions and 19 deletions

View File

@ -1078,6 +1078,10 @@ namespace v2rayN.Handler
{ {
return -1; return -1;
} }
if (routingItem.rules == null)
{
routingItem.rules = new List<RulesItem>();
}
if (blReplace) if (blReplace)
{ {
routingItem.rules.Clear(); routingItem.rules.Clear();
@ -1189,35 +1193,44 @@ namespace v2rayN.Handler
if (config.routings.Count(it => it.locked != true) <= 0) if (config.routings.Count(it => it.locked != true) <= 0)
{ {
//Global //Global
var item1 = new RoutingItem(); var item1 = new RoutingItem()
item1.remarks = "全局(Global)"; {
item1.url = string.Empty; remarks = "全局(Global)",
item1.rules = new List<RulesItem>(); url = string.Empty,
string result1 = Utils.GetEmbedText(Global.CustomRoutingFileName + "global"); };
AddBatchRoutingRules(ref item1, result1); AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "global"));
config.routings.Add(item1); config.routings.Add(item1);
//Bypass the mainland //Bypass the mainland
var item2 = new RoutingItem(); var item2 = new RoutingItem()
item2.remarks = "绕过大陆(Whitelist)"; {
item2.url = string.Empty; remarks = "绕过大陆(Whitelist)",
item2.rules = new List<RulesItem>(); url = string.Empty,
string result2 = Utils.GetEmbedText(Global.CustomRoutingFileName + "white"); };
AddBatchRoutingRules(ref item2, result2); AddBatchRoutingRules(ref item2, Utils.GetEmbedText(Global.CustomRoutingFileName + "white"));
config.routings.Add(item2); 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; config.routingIndex = 0;
} }
if (GetLockedRoutingItem(ref config) == null) if (GetLockedRoutingItem(ref config) == null)
{ {
var item1 = new RoutingItem(); var item1 = new RoutingItem()
item1.remarks = "locked"; {
item1.url = string.Empty; remarks = "locked",
item1.rules = new List<RulesItem>(); url = string.Empty,
item1.locked = true; locked = true,
string result1 = Utils.GetEmbedText(Global.CustomRoutingFileName + "locked"); };
AddBatchRoutingRules(ref item1, result1); AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "locked"));
config.routings.Add(item1); config.routings.Add(item1);
} }

View File

@ -293,6 +293,12 @@ namespace v2rayN.Handler
{ {
AllowAutoRedirect = false 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); HttpClient httpClient = new HttpClient(webRequestHandler);
string url; string url;

View File

@ -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"
}
]

View File

@ -402,6 +402,7 @@
<EmbeddedResource Include="Sample\custom_routing_white" /> <EmbeddedResource Include="Sample\custom_routing_white" />
<EmbeddedResource Include="Sample\custom_routing_global" /> <EmbeddedResource Include="Sample\custom_routing_global" />
<EmbeddedResource Include="Sample\custom_routing_locked" /> <EmbeddedResource Include="Sample\custom_routing_locked" />
<EmbeddedResource Include="Sample\custom_routing_black" />
<Protobuf Include="Protos\Statistics.proto" /> <Protobuf Include="Protos\Statistics.proto" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>