mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-27 11:52:32 +00:00
Enhancements
Add support for exporting SIP002 subscription. Add support for exporting ShadowsocksR subscription. Add support for exporting ShadowsocksD subscription. Add support for exporting v2rayN ver.2 VMess subscription. Add support for exporting Quantumult VMess subscription. Add support for exporting Quantumult X subscription. TODO: Clean up duplicate codes.
This commit is contained in:
152
main.cpp
152
main.cpp
@@ -149,9 +149,6 @@ void readConf()
|
||||
remarksInit(def_exclude_remarks, def_include_remarks);
|
||||
}
|
||||
|
||||
std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &baseConf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR);
|
||||
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, string_array &ruleset_array, string_array &extra_proxy_group, int surge_ver);
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -248,7 +245,8 @@ int main()
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string surge_base_content;
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex")), group = UrlDecode(getUrlArg(argument, "group")), version = getUrlArg(argument, "ver"); int surge_ver = version.size() ? stoi(version) : 3;
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex")), group = UrlDecode(getUrlArg(argument, "group")), version = getUrlArg(argument, "ver");
|
||||
int surge_ver = version.size() ? stoi(version) : 3;
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
@@ -270,11 +268,153 @@ int main()
|
||||
else
|
||||
surge_base_content = webGet(surge_rule_base, getSystemProxy());
|
||||
|
||||
if(update_ruleset_on_request)
|
||||
refreshRulesets();
|
||||
return netchToSurge(nodes, surge_base_content, rulesets, clash_extra_group, surge_ver);
|
||||
});
|
||||
|
||||
append_response("GET", "/ss", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: SIP002"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToSS(nodes);
|
||||
});
|
||||
|
||||
append_response("GET", "/ssr", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: SSR"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToSSR(nodes);
|
||||
});
|
||||
|
||||
append_response("GET", "/v2rayn", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: VMess"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToVMess(nodes);
|
||||
});
|
||||
|
||||
append_response("GET", "/v2rayq", "text/plain;charset=utf-8", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: VMess"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToQuan(nodes);
|
||||
});
|
||||
|
||||
append_response("GET", "/quanx", "text/plain;charset=utf-8", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: Quantumult X"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToQuanX(nodes);
|
||||
});
|
||||
|
||||
append_response("GET", "/ssd", "text/plain", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
{
|
||||
if(!api_mode)
|
||||
readConf();
|
||||
std::string url = UrlDecode(getUrlArg(argument, "url")), include = UrlDecode(getUrlArg(argument, "regex")), group = UrlDecode(getUrlArg(argument, "group"));
|
||||
if(!url.size()) url = default_url;
|
||||
string_array urls = split(url, "|");
|
||||
std::vector<nodeInfo> nodes;
|
||||
int groupID = 0;
|
||||
if(include.size())
|
||||
{
|
||||
eraseElements(def_include_remarks);
|
||||
def_include_remarks.emplace_back(include);
|
||||
}
|
||||
for(std::string &x : urls)
|
||||
{
|
||||
std::cerr<<"Fetching node data from url '"<<x<<"'. Generate target: SSD"<<std::endl;
|
||||
addNodes(x, nodes, groupID);
|
||||
groupID++;
|
||||
}
|
||||
|
||||
return netchToSSD(nodes, group);
|
||||
});
|
||||
|
||||
if(!api_mode)
|
||||
{
|
||||
append_response("GET", "/get", "text/plain;charset=utf-8", [](RESPONSE_CALLBACK_ARGS) -> std::string
|
||||
|
||||
34
misc.cpp
34
misc.cpp
@@ -104,6 +104,11 @@ void StringToWstring(std::wstring& szDst, std::string str)
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
unsigned char ToHex(unsigned char x)
|
||||
{
|
||||
return x > 9 ? x + 55 : x + 48;
|
||||
}
|
||||
|
||||
unsigned char FromHex(unsigned char x)
|
||||
{
|
||||
unsigned char y = '\0';
|
||||
@@ -118,6 +123,30 @@ unsigned char FromHex(unsigned char x)
|
||||
return y;
|
||||
}
|
||||
|
||||
std::string UrlEncode(const std::string& str)
|
||||
{
|
||||
std::string strTemp = "";
|
||||
size_t length = str.length();
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (isalnum((unsigned char)str[i]) ||
|
||||
(str[i] == '-') ||
|
||||
(str[i] == '_') ||
|
||||
(str[i] == '.') ||
|
||||
(str[i] == '~'))
|
||||
strTemp += str[i];
|
||||
else if (str[i] == ' ')
|
||||
strTemp += "+";
|
||||
else
|
||||
{
|
||||
strTemp += '%';
|
||||
strTemp += ToHex((unsigned char)str[i] >> 4);
|
||||
strTemp += ToHex((unsigned char)str[i] % 16);
|
||||
}
|
||||
}
|
||||
return strTemp;
|
||||
}
|
||||
|
||||
std::string UrlDecode(const std::string& str)
|
||||
{
|
||||
std::string strTemp = "";
|
||||
@@ -447,6 +476,11 @@ std::string urlsafe_base64_decode(std::string encoded_string)
|
||||
return base64_decode(urlsafe_base64_reverse(encoded_string));
|
||||
}
|
||||
|
||||
std::string urlsafe_base64_encode(std::string string_to_encode)
|
||||
{
|
||||
return replace_all_distinct(replace_all_distinct(base64_encode(string_to_encode), "+", "-"), "/", "_");
|
||||
}
|
||||
|
||||
std::string getMD5(std::string data)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
|
||||
2
misc.h
2
misc.h
@@ -20,6 +20,7 @@ static const std::string base64_chars =
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
std::string UrlEncode(const std::string& str);
|
||||
std::string UrlDecode(const std::string& str);
|
||||
std::string base64_decode(std::string encoded_string);
|
||||
std::string base64_encode(std::string string_to_encode);
|
||||
@@ -29,6 +30,7 @@ std::string getUrlArg(std::string url, std::string request);
|
||||
std::string replace_all_distinct(std::string str, std::string old_value, std::string new_value);
|
||||
std::string urlsafe_base64_reverse(std::string encoded_string);
|
||||
std::string urlsafe_base64_decode(std::string encoded_string);
|
||||
std::string urlsafe_base64_encode(std::string string_to_encode);
|
||||
std::string UTF8ToGBK(std::string str_src);
|
||||
std::string GBKToUTF8(std::string str_src);
|
||||
std::string trim(const std::string& str);
|
||||
|
||||
295
subexport.cpp
295
subexport.cpp
@@ -5,6 +5,7 @@
|
||||
#include "yamlcpp_extra.h"
|
||||
#include "webget.h"
|
||||
#include "subexport.h"
|
||||
#include "printout.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <rapidjson/writer.h>
|
||||
@@ -18,6 +19,8 @@ extern bool api_mode;
|
||||
|
||||
std::string vmessConstruct(std::string add, std::string port, std::string type, std::string id, std::string aid, std::string net, std::string cipher, std::string path, std::string host, std::string tls, int local_port)
|
||||
{
|
||||
if(path == "")
|
||||
path = "/";
|
||||
rapidjson::StringBuffer sb;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||
writer.StartObject();
|
||||
@@ -116,6 +119,37 @@ std::string ssConstruct(std::string server, std::string port, std::string passwo
|
||||
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)
|
||||
{
|
||||
rapidjson::StringBuffer sb;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||
writer.StartObject();
|
||||
writer.Key("v");
|
||||
writer.String("2");
|
||||
writer.Key("ps");
|
||||
writer.String(remarks.data());
|
||||
writer.Key("add");
|
||||
writer.String(add.data());
|
||||
writer.Key("port");
|
||||
writer.Int(stoi(port));
|
||||
writer.Key("type");
|
||||
writer.String(type.data());
|
||||
writer.Key("id");
|
||||
writer.String(id.data());
|
||||
writer.Key("aid");
|
||||
writer.Int(stoi(aid));
|
||||
writer.Key("net");
|
||||
writer.String(net.data());
|
||||
writer.Key("path");
|
||||
writer.String(path.data());
|
||||
writer.Key("host");
|
||||
writer.String(host.data());
|
||||
writer.Key("tls");
|
||||
writer.String(tls.data());
|
||||
writer.EndObject();
|
||||
return sb.GetString();
|
||||
}
|
||||
|
||||
std::string nodeRename(std::string remark)
|
||||
{
|
||||
string_array vArray;
|
||||
@@ -663,3 +697,264 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, s
|
||||
|
||||
return ini.ToString();
|
||||
}
|
||||
|
||||
std::string netchToSS(std::vector<nodeInfo> &nodes)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
std::string remark, hostname, port, password, method;
|
||||
std::string plugin, pluginopts;
|
||||
std::string proxyStr, allLinks;
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = std::__cxx11::to_string((unsigned short)stoi(GetMember(json, "Port")));
|
||||
password = GetMember(json, "Password");
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
plugin = GetMember(json, "Plugin");
|
||||
pluginopts = GetMember(json, "PluginOption");
|
||||
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDSS:
|
||||
proxyStr = "ss://" + urlsafe_base64_encode(method + ":" + password + "@" + hostname + ":" + port);
|
||||
if(plugin.size() & pluginopts.size())
|
||||
{
|
||||
proxyStr += "/?plugin=" + UrlEncode(plugin + ";" +pluginopts);
|
||||
}
|
||||
proxyStr += "#" + UrlEncode(remark);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
allLinks += proxyStr + "\n";
|
||||
}
|
||||
|
||||
return base64_encode(allLinks);
|
||||
}
|
||||
|
||||
std::string netchToSSR(std::vector<nodeInfo> &nodes)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
std::string remark, hostname, port, password, method;
|
||||
std::string protocol, protoparam, obfs, obfsparam;
|
||||
std::string proxyStr, allLinks;
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = std::__cxx11::to_string((unsigned short)stoi(GetMember(json, "Port")));
|
||||
password = GetMember(json, "Password");
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
protocol = GetMember(json, "Protocol");
|
||||
protoparam = GetMember(json, "ProtocolParam");
|
||||
obfs = GetMember(json, "OBFS");
|
||||
obfsparam = GetMember(json, "OBFSParam");
|
||||
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDSSR:
|
||||
proxyStr = "ssr://" + urlsafe_base64_encode(hostname + ":" + port + ":" + protocol + ":" + method + ":" + obfs + ":" + urlsafe_base64_encode(password) \
|
||||
+ "/?group=" + urlsafe_base64_encode(x.group) + "&remarks=" + urlsafe_base64_encode(remark) \
|
||||
+ "&obfsparam=" + urlsafe_base64_encode(obfsparam) + "&protoparam=" + urlsafe_base64_encode(protoparam));
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
allLinks += proxyStr + "\n";
|
||||
}
|
||||
|
||||
return base64_encode(allLinks);
|
||||
}
|
||||
|
||||
std::string netchToVMess(std::vector<nodeInfo> &nodes)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
std::string remark, hostname, port, method;
|
||||
std::string id, aid, transproto, faketype, host, path, quicsecure, quicsecret;
|
||||
std::string proxyStr, allLinks;
|
||||
bool tlssecure;
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = std::__cxx11::to_string((unsigned short)stoi(GetMember(json, "Port")));
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
id = GetMember(json, "UserID");
|
||||
aid = GetMember(json, "AlterID");
|
||||
transproto = GetMember(json, "TransferProtocol");
|
||||
host = GetMember(json, "Host");
|
||||
path = GetMember(json, "Path");
|
||||
faketype = GetMember(json, "FakeType");
|
||||
tlssecure = GetMember(json, "TLSSecure") == "true";
|
||||
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDVMESS:
|
||||
proxyStr = "vmess://" + base64_encode(vmessLinkConstruct(remark, hostname, port, faketype, id, aid, transproto, path, host, tlssecure ? "tls" : ""));
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
allLinks += proxyStr + "\n";
|
||||
}
|
||||
|
||||
return base64_encode(allLinks);
|
||||
}
|
||||
|
||||
std::string netchToQuan(std::vector<nodeInfo> &nodes)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
std::string remark, hostname, port, method;
|
||||
std::string id, aid, transproto, faketype, host, path, quicsecure, quicsecret;
|
||||
std::string proxyStr, allLinks;
|
||||
bool tlssecure;
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = std::__cxx11::to_string((unsigned short)stoi(GetMember(json, "Port")));
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
id = GetMember(json, "UserID");
|
||||
aid = GetMember(json, "AlterID");
|
||||
transproto = GetMember(json, "TransferProtocol");
|
||||
host = GetMember(json, "Host");
|
||||
path = GetMember(json, "Path");
|
||||
faketype = GetMember(json, "FakeType");
|
||||
tlssecure = GetMember(json, "TLSSecure") == "true";
|
||||
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDVMESS:
|
||||
if(method == "auto")
|
||||
method = "chacha20-ietf-poly1305";
|
||||
proxyStr = remark + " = vmess, " + hostname + ", " + port + ", " + method + ", \"" + id + "\", group=" + x.group;
|
||||
if(transproto == "ws")
|
||||
proxyStr += ", obfs=ws, obfs-path=" + path + ", obfs-header=\"Host: " + host + "\"";
|
||||
if(tlssecure)
|
||||
proxyStr += ", over-tls=true, tls-host=" + host;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
allLinks += "vmess://" + urlsafe_base64_encode(proxyStr) + "\n";
|
||||
}
|
||||
|
||||
return allLinks;
|
||||
}
|
||||
|
||||
std::string netchToQuanX(std::vector<nodeInfo> &nodes)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
std::string remark, hostname, port, method;
|
||||
std::string password, plugin, pluginopts;
|
||||
std::string id, aid, transproto, host, path;
|
||||
std::string proxyStr, allLinks;
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = std::__cxx11::to_string((unsigned short)stoi(GetMember(json, "Port")));
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDVMESS:
|
||||
id = GetMember(json, "UserID");
|
||||
transproto = GetMember(json, "TransferProtocol");
|
||||
host = GetMember(json, "Host");
|
||||
path = GetMember(json, "Path");
|
||||
if(method == "auto")
|
||||
method = "chacha20-ietf-poly1305";
|
||||
proxyStr = "vmess = " + hostname + ":" + port + ", method=" + method + ", password=" + id;
|
||||
if(transproto == "ws")
|
||||
proxyStr += ", obfs=ws, obfs-host=" + host + ", obfs-uri=" + path;
|
||||
break;
|
||||
case SPEEDTEST_MESSAGE_FOUNDSS:
|
||||
password = GetMember(json, "Password");
|
||||
plugin = GetMember(json, "Plugin");
|
||||
pluginopts = GetMember(json, "PluginOption");
|
||||
proxyStr = "shadowsocks = " + hostname + ":" + port + ", method=" + method + ", password=" + password;
|
||||
if(plugin.size() && pluginopts.size())
|
||||
proxyStr += ", " + replace_all_distinct(pluginopts, ";", ", ");
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
proxyStr += ", tag=" + remark;
|
||||
allLinks += proxyStr + "\n";
|
||||
}
|
||||
|
||||
return allLinks;
|
||||
}
|
||||
|
||||
std::string netchToSSD(std::vector<nodeInfo> &nodes, std::string &group)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
rapidjson::StringBuffer sb;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
|
||||
std::string remark, hostname, password, method;
|
||||
std::string plugin, pluginopts;
|
||||
std::string proxyStr, allLinks;
|
||||
int port, index = 0;
|
||||
if(!group.size())
|
||||
group = "SSD";
|
||||
|
||||
writer.StartObject();
|
||||
writer.Key("airport");
|
||||
writer.String(group.data());
|
||||
writer.Key("port");
|
||||
writer.Int(1);
|
||||
writer.Key("encryption");
|
||||
writer.String("aes-128-gcm");
|
||||
writer.Key("password");
|
||||
writer.String("password");
|
||||
writer.Key("servers");
|
||||
writer.StartArray();
|
||||
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
switch(x.linkType)
|
||||
{
|
||||
case SPEEDTEST_MESSAGE_FOUNDSS:
|
||||
json.Parse(x.proxyStr.data());
|
||||
remark = x.remarks = addEmoji(trim(removeEmoji(nodeRename(x.remarks))));
|
||||
hostname = GetMember(json, "Hostname");
|
||||
port = (unsigned short)stoi(GetMember(json, "Port"));
|
||||
password = GetMember(json, "Password");
|
||||
method = GetMember(json, "EncryptMethod");
|
||||
plugin = GetMember(json, "Plugin");
|
||||
pluginopts = GetMember(json, "PluginOption");
|
||||
writer.StartObject();
|
||||
writer.Key("server");
|
||||
writer.String(hostname.data());
|
||||
writer.Key("port");
|
||||
writer.Int(port);
|
||||
writer.Key("encryption");
|
||||
writer.String(method.data());
|
||||
writer.Key("password");
|
||||
writer.String(password.data());
|
||||
writer.Key("plugin");
|
||||
writer.String(plugin.data());
|
||||
writer.Key("plugin_options");
|
||||
writer.String(pluginopts.data());
|
||||
writer.Key("remarks");
|
||||
writer.String(remark.data());
|
||||
writer.Key("id");
|
||||
writer.Int(index);
|
||||
writer.EndObject();
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
writer.EndArray();
|
||||
writer.EndObject();
|
||||
return "ssd://" + base64_encode(sb.GetString());
|
||||
}
|
||||
|
||||
10
subexport.h
10
subexport.h
@@ -9,4 +9,14 @@ struct ruleset_content
|
||||
std::string rule_content;
|
||||
};
|
||||
|
||||
|
||||
std::string netchToClash(std::vector<nodeInfo> &nodes, std::string &baseConf, std::vector<ruleset_content> &ruleset_content_array, string_array &extra_proxy_group, bool clashR);
|
||||
std::string netchToSurge(std::vector<nodeInfo> &nodes, std::string &base_conf, string_array &ruleset_array, string_array &extra_proxy_group, int surge_ver);
|
||||
std::string netchToSS(std::vector<nodeInfo> &nodes);
|
||||
std::string netchToSSR(std::vector<nodeInfo> &nodes);
|
||||
std::string netchToVMess(std::vector<nodeInfo> &nodes);
|
||||
std::string netchToQuanX(std::vector<nodeInfo> &nodes);
|
||||
std::string netchToQuan(std::vector<nodeInfo> &nodes);
|
||||
std::string netchToSSD(std::vector<nodeInfo> &nodes, std::string &group);
|
||||
|
||||
#endif // SUBEXPORT_H_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user