mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-27 20:03:01 +00:00
Optimize codes
This commit is contained in:
@@ -26,4 +26,4 @@ cd base
|
||||
chmod +rx subconverter
|
||||
chmod +r *
|
||||
|
||||
tar czf subconverter_linux64.tar.gz *
|
||||
tar czf ../subconverter_linux64.tar.gz *
|
||||
|
||||
@@ -29,7 +29,7 @@ c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter CMakeFiles/sub
|
||||
cd base
|
||||
chmod +rx subconverter
|
||||
chmod +r *
|
||||
tar czf subconverter_darwin64.tar.gz *
|
||||
tar czf ../subconverter_darwin64.tar.gz *
|
||||
cd ..
|
||||
|
||||
set +xe
|
||||
|
||||
@@ -84,10 +84,7 @@ public:
|
||||
ParseFile(filePath);
|
||||
}
|
||||
|
||||
~INIReader()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
~INIReader() = default;
|
||||
|
||||
/**
|
||||
* @brief Exclude a section with the given name.
|
||||
|
||||
@@ -385,7 +385,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
output_content = netchToClash(nodes, base_content, rca, extra_group, target == "clashr", ext);
|
||||
}
|
||||
else
|
||||
output_content = YAML::Dump(netchToClash(nodes, clash_base, rca, extra_group, target == "clashr", ext));
|
||||
output_content = YAML::Dump(netchToClash(nodes, clash_base, extra_group, target == "clashr", ext));
|
||||
|
||||
if(upload == "true")
|
||||
uploadGist(target, upload_path, output_content, false);
|
||||
@@ -439,7 +439,8 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
INIReader ini = mellow_base;
|
||||
INIReader ini;
|
||||
ini = mellow_base;
|
||||
netchToMellow(nodes, ini, rca, extra_group, ext);
|
||||
output_content = ini.ToString();
|
||||
}
|
||||
@@ -548,7 +549,7 @@ std::string simpleToClashR(RESPONSE_CALLBACK_ARGS)
|
||||
|
||||
std::cerr<<"Generate target: ClashR\n";
|
||||
|
||||
return YAML::Dump(netchToClash(nodes, clash_base, rca, extra_group, true, ext));
|
||||
return YAML::Dump(netchToClash(nodes, clash_base, extra_group, true, ext));
|
||||
}
|
||||
|
||||
void chkArg(int argc, char *argv[])
|
||||
|
||||
@@ -183,7 +183,7 @@ void explodeVmess(std::string vmess, std::string custom_port, int local_port, no
|
||||
GetMember(jsondata, "aid", aid);
|
||||
GetMember(jsondata, "net", net);
|
||||
GetMember(jsondata, "tls", tls);
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
else
|
||||
GetMember(jsondata, "port", port);
|
||||
@@ -265,7 +265,7 @@ void explodeVmessConf(std::string content, std::string custom_port, int local_po
|
||||
//common info
|
||||
json["vmess"][i]["remarks"] >> ps;
|
||||
json["vmess"][i]["address"] >> add;
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
else
|
||||
json["vmess"][i]["port"] >>port;
|
||||
@@ -305,7 +305,7 @@ void explodeVmessConf(std::string content, std::string custom_port, int local_po
|
||||
json["vmess"][i]["security"] >> cipher;
|
||||
group = SS_DEFAULT_GROUP;
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
||||
node.proxyStr = ssConstruct(add, port, id, cipher, "", "", ps, local_port, true);
|
||||
node.proxyStr = ssConstruct(add, port, id, cipher, "", "", ps, local_port, libev);
|
||||
break;
|
||||
case 4: //socks config
|
||||
group = SOCKS_DEFAULT_GROUP;
|
||||
@@ -409,7 +409,7 @@ void explodeSSD(std::string link, bool libev, std::string custom_port, int local
|
||||
GetMember(jsondata["servers"][i], "plugin", plugin);
|
||||
GetMember(jsondata["servers"][i], "plugin_options", pluginopts);
|
||||
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSS;
|
||||
@@ -441,7 +441,7 @@ void explodeSSAndroid(std::string ss, bool libev, std::string custom_port, int l
|
||||
{
|
||||
json["nodes"][i]["remarks"] >> ps;
|
||||
json["nodes"][i]["server"] >> server;
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
else
|
||||
json["nodes"][i]["server_port"] >> port;
|
||||
@@ -490,7 +490,7 @@ void explodeSSConf(std::string content, std::string custom_port, int local_port,
|
||||
for(unsigned int i = 0; i < json["configs"].Size(); i++)
|
||||
{
|
||||
json["configs"][i]["remarks"] >> ps;
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
else
|
||||
json["configs"][i]["server_port"] >> port;
|
||||
@@ -613,7 +613,7 @@ void explodeSSRConf(std::string content, std::string custom_port, int local_port
|
||||
group = SSR_DEFAULT_GROUP;
|
||||
json["configs"][i]["remarks"] >> remarks;
|
||||
json["configs"][i]["server"] >> server;
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
else
|
||||
json["configs"][i]["server_port"] >> port;
|
||||
@@ -669,7 +669,7 @@ void explodeSocks(std::string link, std::string custom_port, nodeInfo &node)
|
||||
{
|
||||
remarks = server + ":" + port;
|
||||
}
|
||||
if(custom_port != "")
|
||||
if(custom_port.size())
|
||||
{
|
||||
port = custom_port;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ void explodeQuan(std::string quan, std::string custom_port, int local_port, node
|
||||
{
|
||||
ps = trim(configs[0]);
|
||||
add = trim(configs[2]);
|
||||
port = trim(configs[3]);
|
||||
port = custom_port.size() ? custom_port : trim(configs[3]);
|
||||
cipher = trim(configs[4]);
|
||||
id = trim(replace_all_distinct(configs[5], "\"", ""));
|
||||
|
||||
@@ -749,7 +749,7 @@ void explodeNetch(std::string netch, bool ss_libev, bool ssr_libev, std::string
|
||||
json["Type"] >> type;
|
||||
json["Remark"] >> remark;
|
||||
json["Hostname"] >> address;
|
||||
json["Port"] >> port;
|
||||
port = custom_port.size() ? custom_port : GetMember(json, "Port");
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
password = GetMember(json, "Password");
|
||||
if(remark == "")
|
||||
@@ -1004,7 +1004,7 @@ void explodeShadowrocket(std::string rocket, std::string custom_port, int local_
|
||||
cipher = userinfo[0];
|
||||
id = userinfo[1];
|
||||
add = userinfo[2];
|
||||
port = userinfo[3];
|
||||
port = custom_port.size() ? custom_port : userinfo[3];
|
||||
remarks = UrlDecode(getUrlArg(addition, "remark"));
|
||||
obfs = getUrlArg(addition, "obfs");
|
||||
if(obfs.size())
|
||||
@@ -1067,6 +1067,8 @@ void explodeKitsunebi(std::string kit, std::string custom_port, int local_port,
|
||||
{
|
||||
port = userinfo[2];
|
||||
}
|
||||
if(custom_port.size())
|
||||
port = custom_port;
|
||||
net = getUrlArg(addition, "network");
|
||||
tls = getUrlArg(addition, "tls") == "true" ? "tls" : "";
|
||||
host = getUrlArg(addition, "ws.host");
|
||||
@@ -1354,7 +1356,7 @@ void explodeSSTap(std::string sstap, std::string custom_port, int local_port, st
|
||||
json["configs"][i]["group"] >> group;
|
||||
json["configs"][i]["remarks"] >> remarks;
|
||||
json["configs"][i]["server"] >> server;
|
||||
json["configs"][i]["server_port"] >> port;
|
||||
port = custom_port.size() ? custom_port : GetMember(json["configs"][i], "server_port");
|
||||
|
||||
if(remarks == "")
|
||||
remarks = server + ":" + port;
|
||||
|
||||
@@ -482,7 +482,7 @@ void groupGenerate(std::string &rule, std::vector<nodeInfo> &nodelist, std::vect
|
||||
}
|
||||
}
|
||||
|
||||
YAML::Node netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR, extra_settings &ext)
|
||||
YAML::Node netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, string_array &extra_proxy_group, bool clashR, extra_settings &ext)
|
||||
{
|
||||
try_config_lock();
|
||||
YAML::Node proxies, singleproxy, singlegroup, original_groups;
|
||||
@@ -692,7 +692,7 @@ std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
return std::string();
|
||||
}
|
||||
|
||||
yamlnode = netchToClash(nodes, yamlnode, ruleset_content_array, extra_proxy_group, clashR, ext);
|
||||
yamlnode = netchToClash(nodes, yamlnode, extra_proxy_group, clashR, ext);
|
||||
|
||||
if(ext.nodelist)
|
||||
return YAML::Dump(yamlnode);
|
||||
|
||||
@@ -25,7 +25,7 @@ struct extra_settings
|
||||
void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset_content_array);
|
||||
void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_content_array, int surge_ver);
|
||||
std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
YAML::Node netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &base, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
YAML::Node netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &base, string_array &extra_proxy_group, bool clashR, extra_settings &ext);
|
||||
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, int surge_ver, extra_settings &ext);
|
||||
std::string netchToMellow(std::vector<nodeInfo> &nodes, std::string &base_conf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, extra_settings &ext);
|
||||
void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, extra_settings &ext);
|
||||
|
||||
Reference in New Issue
Block a user