mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 17:52:19 +00:00
Bugs fix
Fix inconsistent argument name in HTTP and Socks 5 single link. Fix support for some non-standard ShadowsocksD subscription. Fix include/exclude option in URL argument not overriding former settings. Fix template system interpreting some comments in YAML files as line statement. inja: re-implement variable accessing to catch exceptions on using not-exist variable and return an empty value. Optimize codes.
This commit is contained in:
5 files changed
+70
-31
No files matched your search
@@ -6,13 +6,11 @@ allow-lan: {{ global.clash.allow_lan }}
|
||||
mode: Rule
|
||||
log-level: {{ global.clash.log_level }}
|
||||
external-controller: :9090
|
||||
{% if exists("request.clash.dns") %}
|
||||
{% if request.clash.dns == "1" %}
|
||||
dns:
|
||||
enabled: true
|
||||
listen: 1053
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if local.clash.new_field_name == "true" %}
|
||||
proxies: ~
|
||||
proxy-groups: ~
|
||||
|
||||
+3
-1
@@ -3130,7 +3130,9 @@ class Renderer {
|
||||
break;
|
||||
}
|
||||
case Bytecode::Op::Push: {
|
||||
m_stack.emplace_back(*get_imm(bc));
|
||||
try{m_stack.emplace_back(*get_imm(bc));}
|
||||
catch(std::exception &e){m_stack.emplace_back(json());}
|
||||
//m_stack.emplace_back(*get_imm(bc));
|
||||
break;
|
||||
}
|
||||
case Bytecode::Op::Upper: {
|
||||
|
||||
+21
-18
@@ -1085,22 +1085,25 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
//then load external configuration
|
||||
ExternalConfig extconf;
|
||||
loadExternalConfig(config, extconf);
|
||||
if(extconf.clash_rule_base.size())
|
||||
ext_clash_base = extconf.clash_rule_base;
|
||||
if(extconf.surge_rule_base.size())
|
||||
ext_surge_base = extconf.surge_rule_base;
|
||||
if(extconf.surfboard_rule_base.size())
|
||||
ext_surfboard_base = extconf.surfboard_rule_base;
|
||||
if(extconf.mellow_rule_base.size())
|
||||
ext_mellow_base = extconf.mellow_rule_base;
|
||||
if(extconf.quan_rule_base.size())
|
||||
ext_quan_base = extconf.quan_rule_base;
|
||||
if(extconf.quanx_rule_base.size())
|
||||
ext_quanx_base = extconf.quanx_rule_base;
|
||||
if(extconf.loon_rule_base.size())
|
||||
ext_loon_base = extconf.loon_rule_base;
|
||||
if(extconf.sssub_rule_base.size())
|
||||
ext_sssub_base = extconf.sssub_rule_base;
|
||||
if(!ext.nodelist)
|
||||
{
|
||||
if(extconf.clash_rule_base.size())
|
||||
ext_clash_base = extconf.clash_rule_base;
|
||||
if(extconf.surge_rule_base.size())
|
||||
ext_surge_base = extconf.surge_rule_base;
|
||||
if(extconf.surfboard_rule_base.size())
|
||||
ext_surfboard_base = extconf.surfboard_rule_base;
|
||||
if(extconf.mellow_rule_base.size())
|
||||
ext_mellow_base = extconf.mellow_rule_base;
|
||||
if(extconf.quan_rule_base.size())
|
||||
ext_quan_base = extconf.quan_rule_base;
|
||||
if(extconf.quanx_rule_base.size())
|
||||
ext_quanx_base = extconf.quanx_rule_base;
|
||||
if(extconf.loon_rule_base.size())
|
||||
ext_loon_base = extconf.loon_rule_base;
|
||||
if(extconf.sssub_rule_base.size())
|
||||
ext_sssub_base = extconf.sssub_rule_base;
|
||||
}
|
||||
if(extconf.rename.size())
|
||||
ext.rename_array = extconf.rename;
|
||||
if(extconf.emoji.size())
|
||||
@@ -1179,9 +1182,9 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
|
||||
//check custom include/exclude settings
|
||||
if(include.size() && regValid(include))
|
||||
include_remarks.emplace_back(include);
|
||||
include_remarks = string_array{include};
|
||||
if(exclude.size() && regValid(exclude))
|
||||
exclude_remarks.emplace_back(exclude);
|
||||
exclude_remarks = string_array{exclude};
|
||||
|
||||
//start parsing urls
|
||||
string_array stream_temp = safe_get_streams(), time_temp = safe_get_times();
|
||||
|
||||
+45
-10
@@ -316,9 +316,11 @@ void explodeSSD(std::string link, bool libev, const std::string &custom_port, in
|
||||
{
|
||||
Document jsondata;
|
||||
nodeInfo node;
|
||||
unsigned int index = nodes.size();
|
||||
unsigned int index = nodes.size(), listType = 0, listCount = 0;;
|
||||
std::string group, port, method, password, server, remarks;
|
||||
std::string plugin, pluginopts;
|
||||
std::map<unsigned int, std::string> node_map;
|
||||
|
||||
link = urlsafe_base64_decode(link.substr(6));
|
||||
jsondata.Parse(link.c_str());
|
||||
if(jsondata.HasParseError())
|
||||
@@ -326,7 +328,28 @@ void explodeSSD(std::string link, bool libev, const std::string &custom_port, in
|
||||
if(!jsondata.HasMember("servers"))
|
||||
return;
|
||||
GetMember(jsondata, "airport", group);
|
||||
for(unsigned int i = 0; i < jsondata["servers"].Size(); i++)
|
||||
|
||||
if(jsondata["servers"].IsArray())
|
||||
{
|
||||
listType = 0;
|
||||
listCount = jsondata["servers"].Size();
|
||||
}
|
||||
else if(jsondata["servers"].IsObject())
|
||||
{
|
||||
listType = 1;
|
||||
listCount = jsondata["servers"].MemberCount();
|
||||
unsigned int node_index = 0;
|
||||
for(rapidjson::Value::MemberIterator iter = jsondata["servers"].MemberBegin(); iter != jsondata["servers"].MemberEnd(); iter++)
|
||||
{
|
||||
node_map.emplace(node_index, iter->name.GetString());
|
||||
node_index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
rapidjson::Value singlenode;
|
||||
for(unsigned int i = 0; i < listCount; i++)
|
||||
{
|
||||
//get default info
|
||||
GetMember(jsondata, "port", port);
|
||||
@@ -336,13 +359,25 @@ void explodeSSD(std::string link, bool libev, const std::string &custom_port, in
|
||||
GetMember(jsondata, "plugin_options", pluginopts);
|
||||
|
||||
//get server-specific info
|
||||
jsondata["servers"][i]["server"] >> server;
|
||||
GetMember(jsondata["servers"][i], "remarks", remarks);
|
||||
GetMember(jsondata["servers"][i], "port", port);
|
||||
GetMember(jsondata["servers"][i], "encryption", method);
|
||||
GetMember(jsondata["servers"][i], "password", password);
|
||||
GetMember(jsondata["servers"][i], "plugin", plugin);
|
||||
GetMember(jsondata["servers"][i], "plugin_options", pluginopts);
|
||||
switch(listType)
|
||||
{
|
||||
case 0:
|
||||
singlenode = jsondata["servers"][i];
|
||||
break;
|
||||
case 1:
|
||||
singlenode = jsondata["servers"].FindMember(node_map[i].data())->value;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
singlenode["server"] >> server;
|
||||
GetMember(singlenode, "remarks", remarks);
|
||||
GetMember(singlenode, "port", port);
|
||||
GetMember(singlenode, "encryption", method);
|
||||
GetMember(singlenode, "password", password);
|
||||
GetMember(singlenode, "plugin", plugin);
|
||||
GetMember(singlenode, "plugin_options", pluginopts);
|
||||
|
||||
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
@@ -626,7 +661,7 @@ void explodeHTTP(std::string link, const std::string &custom_port, nodeInfo &nod
|
||||
port = getUrlArg(link, "port");
|
||||
username = getUrlArg(link, "user");
|
||||
password = getUrlArg(link, "pass");
|
||||
remarks = UrlDecode(getUrlArg(link, "remark"));
|
||||
remarks = UrlDecode(getUrlArg(link, "remarks"));
|
||||
group = UrlDecode(getUrlArg(link, "group"));
|
||||
|
||||
if(group.empty())
|
||||
|
||||
@@ -31,6 +31,7 @@ int render_template(const std::string &content, const template_args &vars, std::
|
||||
|
||||
m_lexer_config.trim_blocks = true;
|
||||
m_lexer_config.lstrip_blocks = true;
|
||||
m_lexer_config.line_statement = "#~#";
|
||||
m_callbacks.add_callback("UrlDecode", 1, [](inja::Arguments &args)
|
||||
{
|
||||
std::string data = args.at(0)->get<std::string>();
|
||||
|
||||
Reference in new issue
Block a user