Fix logical error causing local rulesets are missing in configurations.
Fix not filtering IP-CIDR6 / PROCESS-NAME rules in Quantumult X rules.
This commit is contained in:
Tindy X committed 2020-04-11 09:57:08 +08:00
1 parent 5f0c2d1b47
commit b52e47ba9c
1 file changed
+25 -25
+25 -25
View File
@@ -30,7 +30,7 @@ const string_array clashr_obfs = {"plain", "http_simple", "http_post", "tls1.2_t
const string_array clash_rule_type = {basic_types, "IP-CIDR6", "SRC-PORT", "DST-PORT"}; const string_array clash_rule_type = {basic_types, "IP-CIDR6", "SRC-PORT", "DST-PORT"};
const string_array surge2_rule_type = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"}; const string_array surge2_rule_type = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"};
const string_array surge_rule_type = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "AND", "OR", "NOT", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"}; const string_array surge_rule_type = {basic_types, "IP-CIDR6", "USER-AGENT", "URL-REGEX", "AND", "OR", "NOT", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"};
const string_array quanx_rule_type = {basic_types, "USER-AGENT", "URL-REGEX", "PROCESS-NAME", "HOST", "HOST-SUFFIX", "HOST-KEYWORD"}; const string_array quanx_rule_type = {basic_types, "USER-AGENT", "HOST", "HOST-SUFFIX", "HOST-KEYWORD"};
const string_array surfb_rule_type = {basic_types, "IP-CIDR6", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"}; const string_array surfb_rule_type = {basic_types, "IP-CIDR6", "PROCESS-NAME", "IN-PORT", "DEST-PORT", "SRC-IP"};
template <typename T> T safe_as (const YAML::Node& node) template <typename T> T safe_as (const YAML::Node& node)
@@ -614,29 +614,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
} }
else else
{ {
if(!fileExist(rule_path)) if(fileExist(rule_path))
{
if(surge_ver > 2)
{
strLine = "RULE-SET," + rule_path + "," + rule_group;
allRules.emplace_back(strLine);
continue;
}
else if(surge_ver == -1 && remote_path_prefix.size())
{
strLine = remote_path_prefix + "/getruleset?type=2&url=" + urlsafe_base64_encode(rule_path) + "&group=" + urlsafe_base64_encode(rule_group);
strLine += ", tag=" + rule_group + ", enabled=true";
base_rule.Set("filter_remote", "{NONAME}", strLine);
continue;
}
else if(surge_ver == -4)
{
strLine = rule_path + "," + rule_group;
base_rule.Set("Remote Rule", "{NONAME}", strLine);
continue;
}
}
else if(startsWith(rule_path, "https://") || startsWith(rule_path, "http://") || startsWith(rule_path, "data:"))
{ {
if(surge_ver > 2 && remote_path_prefix.size()) if(surge_ver > 2 && remote_path_prefix.size())
{ {
@@ -658,6 +636,28 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
continue; continue;
} }
} }
else if(startsWith(rule_path, "https://") || startsWith(rule_path, "http://") || startsWith(rule_path, "data:"))
{
if(surge_ver > 2)
{
strLine = "RULE-SET," + rule_path + "," + rule_group;
allRules.emplace_back(strLine);
continue;
}
else if(surge_ver == -1 && remote_path_prefix.size())
{
strLine = remote_path_prefix + "/getruleset?type=2&url=" + urlsafe_base64_encode(rule_path) + "&group=" + urlsafe_base64_encode(rule_group);
strLine += ", tag=" + rule_group + ", enabled=true";
base_rule.Set("filter_remote", "{NONAME}", strLine);
continue;
}
else if(surge_ver == -4)
{
strLine = rule_path + "," + rule_group;
base_rule.Set("Remote Rule", "{NONAME}", strLine);
continue;
}
}
else else
continue; continue;
retrived_rules = x.rule_content.get(); retrived_rules = x.rule_content.get();
@@ -695,7 +695,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
{ {
case -1: case -1:
case -2: case -2:
if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [strLine](std::string type){return startsWith(strLine, type);})) if(!std::any_of(quanx_rule_type.begin(), quanx_rule_type.end(), [strLine](std::string type){return startsWith(strLine, type);}) || startsWith(strLine, "IP-CIDR6"))
continue; continue;
break; break;
case -3: case -3: