mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-28 12:22:37 +00:00
Enhancements
Fix potential crash when stopping the server. Add support for HTTP nodes in Quantumult X configurations.
This commit is contained in:
@@ -1404,6 +1404,42 @@ bool explodeSurge(std::string surge, const std::string &custom_port, int local_p
|
||||
node.group = TROJAN_DEFAULT_GROUP;
|
||||
node.proxyStr = trojanConstruct(remarks, server, port, password, host, tls == "true");
|
||||
}
|
||||
else if(remarks == "http") //quantumult x style http links
|
||||
{
|
||||
server = trim(configs[0].substr(0, configs[0].rfind(":")));
|
||||
port = custom_port.empty() ? trim(configs[0].substr(configs[0].rfind(":") + 1)) : custom_port;
|
||||
|
||||
for(i = 1; i < configs.size(); i++)
|
||||
{
|
||||
vArray = split(trim(configs[i]), "=");
|
||||
if(vArray.size() != 2)
|
||||
continue;
|
||||
itemName = trim(vArray[0]);
|
||||
itemVal = trim(vArray[1]);
|
||||
switch(hash_(itemName))
|
||||
{
|
||||
case "username"_hash: username = itemVal; break;
|
||||
case "password"_hash: password = itemVal; break;
|
||||
case "tag"_hash: remarks = itemVal; break;
|
||||
case "over-tls"_hash: tls = itemVal; break;
|
||||
default: continue;
|
||||
}
|
||||
}
|
||||
if(remarks.empty())
|
||||
remarks = server + ":" + port;
|
||||
|
||||
if(host.empty() && !isIPv4(server) && !isIPv6(server))
|
||||
host = server;
|
||||
|
||||
if(username == "none")
|
||||
username.clear();
|
||||
if(password == "none")
|
||||
password.clear();
|
||||
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP;
|
||||
node.group = HTTP_DEFAULT_GROUP;
|
||||
node.proxyStr = httpConstruct(remarks, server, port, username, password, tls == "true");
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
|
||||
@@ -1707,6 +1707,15 @@ void netchToQuanX(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rule
|
||||
if(obfsparam.size())
|
||||
proxyStr += ", obfs-host=" + obfsparam;
|
||||
break;
|
||||
case SPEEDTEST_MESSAGE_FOUNDHTTP:
|
||||
id = GetMember(json, "Username");
|
||||
password = GetMember(json, "Password");
|
||||
tlssecure = GetMember(json, "TLSSecure") == "true";
|
||||
|
||||
proxyStr = "http = " + hostname + ":" + port + ", username=" + (id.size() ? id : "none") + ", password=" + (password.size() ? password : "none");
|
||||
if(tlssecure)
|
||||
proxyStr += ", over-tls=true";
|
||||
break;
|
||||
case SPEEDTEST_MESSAGE_FOUNDTROJAN:
|
||||
password = GetMember(json, "Password");
|
||||
host = GetMember(json, "Host");
|
||||
|
||||
@@ -187,7 +187,7 @@ int start_web_server(void *argv)
|
||||
void* httpserver_dispatch(void *arg)
|
||||
{
|
||||
event_base_dispatch((struct event_base*)arg);
|
||||
event_base_free((struct event_base*)arg);
|
||||
event_base_free((struct event_base*)arg); //free resources
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -269,10 +269,8 @@ int start_web_server_multi(void *argv)
|
||||
sleep(200); //block forever until receive stop signal
|
||||
|
||||
for (i = 0; i < nthreads; i++)
|
||||
{
|
||||
event_base_loopbreak(base[i]); //stop the loop
|
||||
event_base_free(base[i]); //free resources
|
||||
}
|
||||
|
||||
closesocket(nfd); //close listener socket
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user