Enhancements

Fix support for parsing Surge HTTP / SOCKS5 nodes.
Optimize codes.
This commit is contained in:
Tindy X committed 2020-05-23 03:00:12 +08:00
1 parent 0de6c06e45
commit 42b00c5ce7
2 files changed
+67 -81

No files matched your search

+15 -6
View File
@@ -604,7 +604,7 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
*/
if(lineSize)
{
strLine = regTrim(strLine);
strLine = trim(trim_of(strLine, '\r'));
lineSize = strLine.size();
}
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
@@ -688,7 +688,7 @@ std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content
lineSize = strLine.size();
if(lineSize)
{
strLine = regTrim(strLine);
strLine = trim(trim_of(strLine, '\r'));
lineSize = strLine.size();
}
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
@@ -846,7 +846,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
*/
if(lineSize)
{
strLine = regTrim(strLine);
strLine = trim(trim_of(strLine, '\r'));
lineSize = strLine.size();
}
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
@@ -1448,12 +1448,20 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
local_port++;
break;
case SPEEDTEST_MESSAGE_FOUNDSOCKS:
proxy = "socks5, " + hostname + ", " + port + ", " + username + ", " + password;
proxy = "socks5, " + hostname + ", " + port;
if(username.size())
proxy += ", username=" + username;
if(password.size())
proxy += ", password=" + password;
if(scv)
proxy += ", skip-cert-verify=1";
break;
case SPEEDTEST_MESSAGE_FOUNDHTTP:
proxy = "http, " + hostname + ", " + port + ", " + username + ", " + password;
proxy = "http, " + hostname + ", " + port;
if(username.size())
proxy += ", username=" + username;
if(password.size())
proxy += ", password=" + password;
proxy += std::string(", tls=") + (type == "HTTPS" ? "true" : "false");
if(scv)
proxy += ", skip-cert-verify=1";
@@ -1610,7 +1618,7 @@ std::string netchToSS(std::vector<nodeInfo> &nodes, extra_settings &ext)
proxyStr = "ss://" + urlsafe_base64_encode(method + ":" + password) + "@" + hostname + ":" + port;
if(plugin.size() && pluginopts.size())
{
proxyStr += "/?plugin=" + UrlEncode(plugin + ";" +pluginopts);
proxyStr += "/?plugin=" + UrlEncode(plugin + ";" + pluginopts);
}
proxyStr += "#" + UrlEncode(remark);
break;
@@ -2098,6 +2106,7 @@ std::string netchToQuanX(std::vector<nodeInfo> &nodes, std::string &base_conf, s
ini.AddDirectSaveSection("rewrite_local");
ini.AddDirectSaveSection("task_local");
ini.AddDirectSaveSection("mitm");
ini.AddDirectSaveSection("server_remote");
if(!ext.nodelist && ini.Parse(base_conf) != 0)
return std::string();