diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 90721217..7d44bb0c 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -90,6 +90,10 @@ public class Global public const int Hysteria2DefaultHopInt = 10; + public const string PolicyGroupExcludeKeywords = @"剩余|过期|到期|重置|[Rr]emaining|[Ee]xpir|[Rr]eset"; + + public const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$"; + public static readonly List IEProxyProtocols = [ "{ip}:{http_port}", diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 091d31eb..e5b6fec3 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1163,23 +1163,6 @@ public static class ConfigHandler return 0; } - // Matches subscription-info noise words in both Chinese and English. - // Chinese: 剩余(remaining), 过期/到期(expired/expiry), 重置(reset) - // English: remaining, expir(e/ed/y), reset - private const string PolicyGroupExcludeKeywords = @"剩余|过期|到期|重置|[Rr]emaining|[Ee]xpir|[Rr]eset"; - - private const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$"; - - /// - /// Combines a region pattern with PolicyGroupDefaultAllFilter so results must - /// match the region keyword AND not contain expiry/traffic noise words (CN + EN). - /// Result pattern: ^(?!.*(?:...excludeKeywords...)).*(?:regionPattern).*$ - /// - private static string CombineWithDefaultAllFilter(string regionPattern) - { - return $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*(?:{regionPattern}).*$"; - } - /// /// Create a group server that combines multiple servers for load balancing /// Generates a PolicyGroup profile with references to the sub-items @@ -1217,7 +1200,7 @@ public static class ConfigHandler MultipleLoad = EMultipleLoad.LeastPing, GroupType = profile.ConfigType.ToString(), SubChildItems = subId, - Filter = PolicyGroupDefaultAllFilter, + Filter = Global.PolicyGroupDefaultAllFilter, }; profile.SetProtocolExtra(extraItem); var ret = await AddServerCommon(config, profile, true); @@ -1226,6 +1209,11 @@ public static class ConfigHandler return result; } + private static string CombineWithDefaultAllFilter(string regionPattern) + { + return $"^(?!.*(?:{Global.PolicyGroupExcludeKeywords})).*(?:{regionPattern}).*$"; + } + private static readonly Dictionary PolicyGroupRegionFilters = new() { { "JP", "日本|\\b[Jj][Pp]\\b|🇯🇵|[Jj]apan" },