mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 10:52:21 +00:00
Bug fixes
Fix logical error for customizing rulesets and groups. Fix parsing error for some VMess subscriptions. Optimize codes.
This commit is contained in:
28
src/main.cpp
28
src/main.cpp
@@ -25,7 +25,7 @@ string_array def_exclude_remarks, def_include_remarks, rulesets, stream_rules, t
|
|||||||
std::vector<ruleset_content> ruleset_content_array;
|
std::vector<ruleset_content> ruleset_content_array;
|
||||||
std::string listen_address = "127.0.0.1", default_url, managed_config_prefix;
|
std::string listen_address = "127.0.0.1", default_url, managed_config_prefix;
|
||||||
int listen_port = 25500, max_pending_connections = 10, max_concurrent_threads = 4;
|
int listen_port = 25500, max_pending_connections = 10, max_concurrent_threads = 4;
|
||||||
bool api_mode = true, write_managed_config = false, update_ruleset_on_request = false, overwrite_original_rules = true;
|
bool api_mode = true, write_managed_config = false, enable_rule_generator = true, update_ruleset_on_request = false, overwrite_original_rules = true;
|
||||||
bool print_debug_info = false, cfw_child_process = false;
|
bool print_debug_info = false, cfw_child_process = false;
|
||||||
std::string access_token;
|
std::string access_token;
|
||||||
extern std::string custom_group;
|
extern std::string custom_group;
|
||||||
@@ -457,6 +457,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
std::vector<ruleset_content> rca;
|
std::vector<ruleset_content> rca;
|
||||||
extra_settings ext;
|
extra_settings ext;
|
||||||
std::string subInfo;
|
std::string subInfo;
|
||||||
|
bool ruleset_group_updated = false;
|
||||||
|
|
||||||
if(std::find(regex_blacklist.cbegin(), regex_blacklist.cend(), include) != regex_blacklist.cend() || std::find(regex_blacklist.cbegin(), regex_blacklist.cend(), exclude) != regex_blacklist.cend())
|
if(std::find(regex_blacklist.cbegin(), regex_blacklist.cend(), include) != regex_blacklist.cend() || std::find(regex_blacklist.cbegin(), regex_blacklist.cend(), exclude) != regex_blacklist.cend())
|
||||||
return "Invalid request!";
|
return "Invalid request!";
|
||||||
@@ -526,10 +527,11 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
{
|
{
|
||||||
extra_ruleset = extconf.surge_ruleset;
|
extra_ruleset = extconf.surge_ruleset;
|
||||||
refreshRulesets(extra_ruleset, rca);
|
refreshRulesets(extra_ruleset, rca);
|
||||||
|
ruleset_group_updated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(update_ruleset_on_request || cfw_child_process)
|
if(update_ruleset_on_request)
|
||||||
refreshRulesets(rulesets, ruleset_content_array);
|
refreshRulesets(rulesets, ruleset_content_array);
|
||||||
rca = ruleset_content_array;
|
rca = ruleset_content_array;
|
||||||
}
|
}
|
||||||
@@ -542,6 +544,8 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
extra_group = split(groups, "@");
|
extra_group = split(groups, "@");
|
||||||
if(!extra_group.size())
|
if(!extra_group.size())
|
||||||
extra_group = clash_extra_group;
|
extra_group = clash_extra_group;
|
||||||
|
else
|
||||||
|
ruleset_group_updated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
extra_group = clash_extra_group;
|
extra_group = clash_extra_group;
|
||||||
@@ -552,20 +556,24 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
extra_ruleset = split(ruleset, "@");
|
extra_ruleset = split(ruleset, "@");
|
||||||
if(!extra_ruleset.size())
|
if(!extra_ruleset.size())
|
||||||
{
|
{
|
||||||
if(update_ruleset_on_request || cfw_child_process)
|
if(update_ruleset_on_request)
|
||||||
refreshRulesets(rulesets, ruleset_content_array);
|
refreshRulesets(rulesets, ruleset_content_array);
|
||||||
rca = ruleset_content_array;
|
rca = ruleset_content_array;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
refreshRulesets(extra_ruleset, rca);
|
refreshRulesets(extra_ruleset, rca);
|
||||||
|
ruleset_group_updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(update_ruleset_on_request || cfw_child_process)
|
if(enable_rule_generator)
|
||||||
refreshRulesets(rulesets, ruleset_content_array);
|
{
|
||||||
rca = ruleset_content_array;
|
if(update_ruleset_on_request || cfw_child_process)
|
||||||
|
refreshRulesets(rulesets, ruleset_content_array);
|
||||||
|
rca = ruleset_content_array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,6 +600,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
|
|
||||||
ext.nodelist = nodelist == "true";
|
ext.nodelist = nodelist == "true";
|
||||||
ext.surge_ssr_path = surge_ssr_path;
|
ext.surge_ssr_path = surge_ssr_path;
|
||||||
|
ext.enable_rule_generator = enable_rule_generator;
|
||||||
|
|
||||||
//loading urls
|
//loading urls
|
||||||
string_array urls = split(url, "|");
|
string_array urls = split(url, "|");
|
||||||
@@ -640,7 +649,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
if(target == "clash" || target == "clashr")
|
if(target == "clash" || target == "clashr")
|
||||||
{
|
{
|
||||||
std::cerr<<"Clash"<<((target == "clashr") ? "R" : "")<<std::endl;
|
std::cerr<<"Clash"<<((target == "clashr") ? "R" : "")<<std::endl;
|
||||||
if(rca.size() || extra_group.size() || update_ruleset_on_request || ext_clash_base != clash_rule_base)
|
if(ruleset_group_updated || update_ruleset_on_request || ext_clash_base != clash_rule_base)
|
||||||
{
|
{
|
||||||
if(fileExist(ext_clash_base))
|
if(fileExist(ext_clash_base))
|
||||||
base_content = fileGet(ext_clash_base, false);
|
base_content = fileGet(ext_clash_base, false);
|
||||||
@@ -694,7 +703,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
else if(target == "mellow")
|
else if(target == "mellow")
|
||||||
{
|
{
|
||||||
std::cerr<<"Mellow"<<std::endl;
|
std::cerr<<"Mellow"<<std::endl;
|
||||||
if(rca.size() || extra_group.size() || update_ruleset_on_request || ext_mellow_base != mellow_rule_base)
|
if(ruleset_group_updated || update_ruleset_on_request || ext_mellow_base != mellow_rule_base)
|
||||||
{
|
{
|
||||||
if(fileExist(ext_mellow_base))
|
if(fileExist(ext_mellow_base))
|
||||||
base_content = fileGet(ext_mellow_base, false);
|
base_content = fileGet(ext_mellow_base, false);
|
||||||
@@ -866,7 +875,10 @@ void chkArg(int argc, char *argv[])
|
|||||||
for(int i = 1; i < argc; i++)
|
for(int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if(strcmp(argv[i], "-cfw") == 0)
|
if(strcmp(argv[i], "-cfw") == 0)
|
||||||
|
{
|
||||||
cfw_child_process = true;
|
cfw_child_process = true;
|
||||||
|
update_ruleset_on_request = true;
|
||||||
|
}
|
||||||
else if(strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--file") == 0)
|
else if(strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--file") == 0)
|
||||||
pref_path.assign(argv[++i]);
|
pref_path.assign(argv[++i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,10 +563,10 @@ bool regMatch(std::string src, std::string match)
|
|||||||
bool regMatch(std::string src, std::string target)
|
bool regMatch(std::string src, std::string target)
|
||||||
{
|
{
|
||||||
jp::Regex reg;
|
jp::Regex reg;
|
||||||
reg.setPattern(target).addModifier("gm").compile();
|
reg.setPattern(target).addModifier("gm").addPcre2Option(PCRE2_ANCHORED|PCRE2_ENDANCHORED).compile();
|
||||||
if(!reg)
|
if(!reg)
|
||||||
return false;
|
return false;
|
||||||
return reg.replace(src, "$0") == src;
|
return reg.match(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool regFind(std::string src, std::string target)
|
bool regFind(std::string src, std::string target)
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ std::string modSSMD5 = "f7653207090ce3389115e9c88541afe0";
|
|||||||
|
|
||||||
template <typename T> void operator >> (const YAML::Node& node, T& i)
|
template <typename T> void operator >> (const YAML::Node& node, T& i)
|
||||||
{
|
{
|
||||||
i = node.as<T>();
|
if(node.IsDefined()) //fail-safe
|
||||||
|
i = node.as<T>();
|
||||||
};
|
};
|
||||||
|
|
||||||
void explodeVmess(std::string vmess, std::string custom_port, int local_port, nodeInfo &node)
|
void explodeVmess(std::string vmess, std::string custom_port, int local_port, nodeInfo &node)
|
||||||
|
|||||||
@@ -1340,8 +1340,6 @@ void netchToQuan(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rules
|
|||||||
proxyStr = remark + " = vmess, " + hostname + ", " + port + ", " + method + ", \"" + id + "\", group=" + x.group;
|
proxyStr = remark + " = vmess, " + hostname + ", " + port + ", " + method + ", \"" + id + "\", group=" + x.group;
|
||||||
if(tlssecure)
|
if(tlssecure)
|
||||||
proxyStr += ", over-tls=true, tls-host=" + host;
|
proxyStr += ", over-tls=true, tls-host=" + host;
|
||||||
if(ext.skip_cert_verify)
|
|
||||||
proxyStr += ", certificate=0";
|
|
||||||
if(transproto == "ws")
|
if(transproto == "ws")
|
||||||
proxyStr += ", obfs=ws, obfs-path=\"" + path + "\", obfs-header=\"Host: " + host + "\"";
|
proxyStr += ", obfs=ws, obfs-path=\"" + path + "\", obfs-header=\"Host: " + host + "\"";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user