mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-01 17:25:02 +00:00
Enhancements
Add UDP, TCP Fast Open options for exporting Surge and Quantumult X subscriptions. Add UDP option for exporting Clash subscriptions. Add HTTP proxy detection for Clash and Surge subscriptions.
This commit is contained in:
6 files changed
+84
-3
No files matched your search
@@ -217,7 +217,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
{
|
||||
std::string target = getUrlArg(argument, "target"), url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex")), emoji = getUrlArg(argument, "emoji");
|
||||
std::string group = UrlDecode(getUrlArg(argument, "group")), upload = getUrlArg(argument, "upload"), upload_path = getUrlArg(argument, "upload_path"), version = getUrlArg(argument, "ver");
|
||||
std::string append_type = getUrlArg(argument, "append_type");
|
||||
std::string append_type = getUrlArg(argument, "append_type"), tfo = getUrlArg(argument, "tfo"), udp = getUrlArg(argument, "udp"), nodelist = getUrlArg(argument, "list");
|
||||
std::string base_content, output_content;
|
||||
string_array extra_group;
|
||||
std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups"));
|
||||
@@ -246,6 +246,10 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
else
|
||||
proxy = proxy_subscription;
|
||||
|
||||
ext.tfo = tfo == "true";
|
||||
ext.udp = udp == "true";
|
||||
ext.nodelist = nodelist == "true";
|
||||
|
||||
if(!url.size())
|
||||
url = default_url;
|
||||
if(!url.size() || !target.size())
|
||||
@@ -302,7 +306,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
if(upload == "true")
|
||||
uploadGist("surge" + version, upload_path, output_content, true);
|
||||
|
||||
if(write_managed_config && managed_config_prefix.size())
|
||||
if(write_managed_config && managed_config_prefix.size() && !ext.nodelist)
|
||||
output_content = "#!MANAGED-CONFIG " + managed_config_prefix + "/sub?" + argument + "\n\n" + output_content;
|
||||
return output_content;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,14 @@
|
||||
#define SPEEDTEST_MESSAGE_GOTUPD 31
|
||||
#define SPEEDTEST_MESSAGE_FOUNDSSTAP 32
|
||||
#define SPEEDTEST_MESSAGE_FOUNDNETCH 33
|
||||
#define SPEEDTEST_MESSAGE_FOUNDHTTP 34
|
||||
#define SPEEDTEST_MESSAGE_EOF 49
|
||||
|
||||
#define SS_DEFAULT_GROUP "SSProvider"
|
||||
#define SSR_DEFAULT_GROUP "SSRProvider"
|
||||
#define V2RAY_DEFAULT_GROUP "V2RayProvider"
|
||||
#define SOCKS_DEFAULT_GROUP "SocksProvider"
|
||||
#define HTTP_DEFAULT_GROUP "HTTPProvider"
|
||||
|
||||
void printMsg(int index, nodeInfo *node, bool rpcmode);
|
||||
void printMsgWithDict(int index, bool rpcmode, std::vector<std::string> dict, std::vector<std::string> trans);
|
||||
|
||||
@@ -144,6 +144,11 @@ std::string socksConstruct(std::string remarks, std::string server, std::string
|
||||
{
|
||||
return "user=" + username + "&pass=" + password;
|
||||
}
|
||||
|
||||
std::string httpConstruct(std::string remarks, std::string server, std::string port, std::string username, std::string password)
|
||||
{
|
||||
return "user=" + username + "&pass=" + password;
|
||||
}
|
||||
*/
|
||||
|
||||
void explodeVmess(std::string vmess, std::string custom_port, int local_port, nodeInfo &node)
|
||||
@@ -962,6 +967,19 @@ void explodeClash(Node yamlnode, std::string custom_port, int local_port, std::v
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDSSR;
|
||||
node.proxyStr = ssrConstruct(group, ps, base64_encode(ps), server, port, protocol, cipher, obfs, password, obfsparam, protoparam, local_port, ssr_libev);
|
||||
}
|
||||
else if(proxytype == "http")
|
||||
{
|
||||
group = HTTP_DEFAULT_GROUP;
|
||||
|
||||
if(yamlnode["Proxy"][i]["username"].IsDefined() && yamlnode["Proxy"][i]["password"].IsDefined())
|
||||
{
|
||||
yamlnode["Proxy"][i]["username"] >> user;
|
||||
yamlnode["Proxy"][i]["password"] >> password;
|
||||
}
|
||||
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP;
|
||||
node.proxyStr = httpConstruct(ps, server, port, user, password);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
@@ -1239,6 +1257,17 @@ bool explodeSurge(std::string surge, std::string custom_port, int local_port, st
|
||||
node.group = V2RAY_DEFAULT_GROUP;
|
||||
node.proxyStr = vmessConstruct(server, port, "", id, "0", net, method, path, host, tls, local_port);
|
||||
}
|
||||
else if(configs[0] == "http") //http proxy
|
||||
{
|
||||
node.linkType = SPEEDTEST_MESSAGE_FOUNDHTTP;
|
||||
node.group = HTTP_DEFAULT_GROUP;
|
||||
if(configs.size() >= 5)
|
||||
{
|
||||
username = trim(configs[2]);
|
||||
password = trim(configs[3]);
|
||||
}
|
||||
node.proxyStr = httpConstruct(remarks, server, port, username, password);
|
||||
}
|
||||
else if(remarks == "shadowsocks") //quantumult style ss/ssr link
|
||||
{
|
||||
server = trim(configs[0].substr(0, configs[0].rfind(":")));
|
||||
|
||||
@@ -11,6 +11,7 @@ std::string vmessConstruct(std::string add, std::string port, std::string type,
|
||||
std::string ssrConstruct(std::string group, std::string remarks, std::string remarks_base64, std::string server, std::string port, std::string protocol, std::string method, std::string obfs, std::string password, std::string obfsparam, std::string protoparam, int local_port, bool libev);
|
||||
std::string ssConstruct(std::string server, std::string port, std::string password, std::string method, std::string plugin, std::string pluginopts, std::string remarks, int local_port, bool libev);
|
||||
std::string socksConstruct(std::string remarks, std::string server, std::string port, std::string username, std::string password);
|
||||
std::string httpConstruct(std::string remarks, std::string server, std::string port, std::string username, std::string password);
|
||||
void explodeVmess(std::string vmess, std::string custom_port, int local_port, nodeInfo &node);
|
||||
void explodeSSR(std::string ssr, bool ss_libev, bool libev, std::string custom_port, int local_port, nodeInfo &node);
|
||||
void explodeSS(std::string ss, bool libev, std::string custom_port, int local_port, nodeInfo &node);
|
||||
|
||||
+43
-1
@@ -151,6 +151,29 @@ std::string socksConstruct(std::string remarks, std::string server, std::string
|
||||
return sb.GetString();
|
||||
}
|
||||
|
||||
std::string httpConstruct(std::string remarks, std::string server, std::string port, std::string username, std::string password)
|
||||
{
|
||||
if(!port.size())
|
||||
port = "0";
|
||||
rapidjson::StringBuffer sb;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||
writer.StartObject();
|
||||
writer.Key("Type");
|
||||
writer.String("HTTP");
|
||||
writer.Key("Remark");
|
||||
writer.String(remarks.data());
|
||||
writer.Key("Hostname");
|
||||
writer.String(server.data());
|
||||
writer.Key("Port");
|
||||
writer.Int(stoi(port));
|
||||
writer.Key("Username");
|
||||
writer.String(username.data());
|
||||
writer.Key("Password");
|
||||
writer.String(password.data());
|
||||
writer.EndObject();
|
||||
return sb.GetString();
|
||||
}
|
||||
|
||||
std::string vmessLinkConstruct(std::string remarks, std::string add, std::string port, std::string type, std::string id, std::string aid, std::string net, std::string path, std::string host, std::string tls)
|
||||
{
|
||||
if(!port.size())
|
||||
@@ -461,6 +484,8 @@ std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
singleproxy["name"] = remark;
|
||||
singleproxy["server"] = hostname;
|
||||
singleproxy["port"] = (unsigned short)stoi(port);
|
||||
if(ext.udp)
|
||||
singleproxy["udp"] = true;
|
||||
singleproxy.SetStyle(YAML::EmitterStyle::Flow);
|
||||
proxies.push_back(singleproxy);
|
||||
remarks_list.emplace_back(remark);
|
||||
@@ -568,6 +593,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
std::string plugin, pluginopts;
|
||||
std::string id, aid, transproto, faketype, host, path, quicsecure, quicsecret;
|
||||
std::string url, group;
|
||||
std::string output_nodelist;
|
||||
std::vector<nodeInfo> nodelist;
|
||||
bool tlssecure;
|
||||
string_array vArray, remarks_list, filtered_nodelist;
|
||||
@@ -650,11 +676,23 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
}
|
||||
else
|
||||
continue;
|
||||
ini.Set(remark, proxy);
|
||||
|
||||
if(ext.tfo)
|
||||
proxy += ", tfo=true";
|
||||
if(ext.udp)
|
||||
proxy += ", udp-relay=true";
|
||||
|
||||
if(ext.nodelist)
|
||||
output_nodelist += remark + " = " + proxy + "\n";
|
||||
else
|
||||
ini.Set("{NONAME}", remark + " = " + proxy);
|
||||
nodelist.emplace_back(x);
|
||||
remarks_list.emplace_back(remark);
|
||||
}
|
||||
|
||||
if(ext.nodelist)
|
||||
return output_nodelist;
|
||||
|
||||
ini.SetCurrentSection("Proxy Group");
|
||||
for(std::string &x : extra_proxy_group)
|
||||
{
|
||||
@@ -1017,6 +1055,10 @@ std::string netchToQuanX(std::vector<nodeInfo> &nodes, extra_settings &ext)
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if(ext.tfo)
|
||||
proxyStr += ", fast-open=true";
|
||||
if(ext.udp)
|
||||
proxyStr += ", udp-relay=true";
|
||||
proxyStr += ", tag=" + remark;
|
||||
allLinks += proxyStr + "\n";
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ struct extra_settings
|
||||
bool add_emoji = false;
|
||||
bool remove_emoji = false;
|
||||
bool append_proxy_type = true;
|
||||
bool udp = false;
|
||||
bool tfo = false;
|
||||
bool nodelist = false;
|
||||
string_array include_remarks;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user