mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
GeoPrefix move to Global
This commit is contained in:
parent
81d59ce773
commit
1760a92507
5 changed files with 21 additions and 19 deletions
|
|
@ -67,6 +67,8 @@ public class Global
|
||||||
public const string AsIs = "AsIs";
|
public const string AsIs = "AsIs";
|
||||||
public const string IPIfNonMatch = "IPIfNonMatch";
|
public const string IPIfNonMatch = "IPIfNonMatch";
|
||||||
public const string IPOnDemand = "IPOnDemand";
|
public const string IPOnDemand = "IPOnDemand";
|
||||||
|
public const string GeoSitePrefix = "geosite:";
|
||||||
|
public const string GeoIPPrefix = "geoip:";
|
||||||
|
|
||||||
public const string UserEMail = "t@t.tt";
|
public const string UserEMail = "t@t.tt";
|
||||||
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||||
|
|
|
||||||
|
|
@ -310,9 +310,9 @@ public partial class CoreConfigSingboxService
|
||||||
|
|
||||||
foreach (var ip in ipItems)
|
foreach (var ip in ipItems)
|
||||||
{
|
{
|
||||||
if (ip.StartsWith("geoip:", StringComparison.OrdinalIgnoreCase))
|
if (ip.StartsWith(Global.GeoIPPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var region = ip["geoip:".Length..];
|
var region = ip[Global.GeoIPPrefix.Length..];
|
||||||
if (string.IsNullOrEmpty(region))
|
if (string.IsNullOrEmpty(region))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -406,10 +406,10 @@ public partial class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (domain.StartsWith("geosite:"))
|
else if (domain.StartsWith(Global.GeoSitePrefix))
|
||||||
{
|
{
|
||||||
rule.geosite ??= [];
|
rule.geosite ??= [];
|
||||||
rule.geosite?.Add(domain.Substring(8));
|
rule.geosite?.Add(domain[Global.GeoSitePrefix.Length..]);
|
||||||
}
|
}
|
||||||
else if (domain.StartsWith("regexp:"))
|
else if (domain.StartsWith("regexp:"))
|
||||||
{
|
{
|
||||||
|
|
@ -450,28 +450,28 @@ public partial class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (address.Equals("geoip:private"))
|
else if (address.Equals($"{Global.GeoIPPrefix}private"))
|
||||||
{
|
{
|
||||||
rule.ip_is_private = true;
|
rule.ip_is_private = true;
|
||||||
}
|
}
|
||||||
else if (address.StartsWith("geoip:"))
|
else if (address.StartsWith(Global.GeoIPPrefix))
|
||||||
{
|
{
|
||||||
rule.geoip ??= new();
|
rule.geoip ??= [];
|
||||||
rule.geoip?.Add(address.Substring(6));
|
rule.geoip?.Add(address[Global.GeoIPPrefix.Length..]);
|
||||||
}
|
}
|
||||||
else if (address.Equals("geoip:!private"))
|
else if (address.Equals($"{Global.GeoIPPrefix}!private"))
|
||||||
{
|
{
|
||||||
rule.ip_is_private = false;
|
rule.ip_is_private = false;
|
||||||
}
|
}
|
||||||
else if (address.StartsWith("geoip:!"))
|
else if (address.StartsWith($"{Global.GeoIPPrefix}!"))
|
||||||
{
|
{
|
||||||
rule.geoip ??= new();
|
rule.geoip ??= [];
|
||||||
rule.geoip?.Add(address.Substring(6));
|
rule.geoip?.Add(address.Substring($"{Global.GeoIPPrefix}!".Length));
|
||||||
rule.invert = true;
|
rule.invert = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rule.ip_cidr ??= new();
|
rule.ip_cidr ??= [];
|
||||||
rule.ip_cidr?.Add(address);
|
rule.ip_cidr?.Add(address);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ public partial class CoreConfigV2rayService
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var region in from ip in expectedIPs
|
foreach (var region in from ip in expectedIPs
|
||||||
where ip.StartsWith("geoip:", StringComparison.OrdinalIgnoreCase)
|
where ip.StartsWith(Global.GeoIPPrefix, StringComparison.OrdinalIgnoreCase)
|
||||||
select ip["geoip:".Length..]
|
select ip[Global.GeoIPPrefix.Length..]
|
||||||
into region
|
into region
|
||||||
where !string.IsNullOrEmpty(region)
|
where !string.IsNullOrEmpty(region)
|
||||||
select region)
|
select region)
|
||||||
|
|
@ -197,7 +197,7 @@ public partial class CoreConfigV2rayService
|
||||||
|
|
||||||
if (item.OutboundTag == Global.DirectTag)
|
if (item.OutboundTag == Global.DirectTag)
|
||||||
{
|
{
|
||||||
if (normalizedDomain.StartsWith("geosite:") || normalizedDomain.StartsWith("ext:"))
|
if (normalizedDomain.StartsWith(Global.GeoSitePrefix) || normalizedDomain.StartsWith("ext:"))
|
||||||
{
|
{
|
||||||
var isExpectedDomain = !regionName.IsNullOrEmpty()
|
var isExpectedDomain = !regionName.IsNullOrEmpty()
|
||||||
|| normalizedDomain.EndsWith($"-{regionName}")
|
|| normalizedDomain.EndsWith($"-{regionName}")
|
||||||
|
|
@ -212,7 +212,7 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
else if (item.OutboundTag != Global.BlockTag)
|
else if (item.OutboundTag != Global.BlockTag)
|
||||||
{
|
{
|
||||||
if (normalizedDomain.StartsWith("geosite:") || normalizedDomain.StartsWith("ext:"))
|
if (normalizedDomain.StartsWith(Global.GeoSitePrefix) || normalizedDomain.StartsWith("ext:"))
|
||||||
{
|
{
|
||||||
proxyGeositeList.Add(normalizedDomain);
|
proxyGeositeList.Add(normalizedDomain);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -375,8 +375,8 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
foreach (var item in rules ?? [])
|
foreach (var item in rules ?? [])
|
||||||
{
|
{
|
||||||
AddPrefixedItems(item.Ip, "geoip:", geoipFiles);
|
AddPrefixedItems(item.Ip, Global.GeoIPPrefix, geoipFiles);
|
||||||
AddPrefixedItems(item.Domain, "geosite:", geoSiteFiles);
|
AddPrefixedItems(item.Domain, Global.GeoSitePrefix, geoSiteFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue