mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-09-26 23:09:20 +08:00
Merge pull request #19 from cpploveme/master
Some checks failed
GitHub CI / Linux x86 Build (push) Has been cancelled
GitHub CI / Linux x86_64 Build (push) Has been cancelled
GitHub CI / Linux armv7 Build (push) Has been cancelled
GitHub CI / Linux aarch64 Build (push) Has been cancelled
GitHub CI / Linux armhf Build (push) Has been cancelled
GitHub CI / macOS Build (push) Has been cancelled
GitHub CI / Windows x86_64 Build (push) Has been cancelled
GitHub CI / Windows x86 Build (push) Has been cancelled
GitHub CI / Upload-Release (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/386) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/amd64) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/arm/v7) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/arm64) (push) Has been cancelled
Publish Docker Image / Merge (push) Has been cancelled
Some checks failed
GitHub CI / Linux x86 Build (push) Has been cancelled
GitHub CI / Linux x86_64 Build (push) Has been cancelled
GitHub CI / Linux armv7 Build (push) Has been cancelled
GitHub CI / Linux aarch64 Build (push) Has been cancelled
GitHub CI / Linux armhf Build (push) Has been cancelled
GitHub CI / macOS Build (push) Has been cancelled
GitHub CI / Windows x86_64 Build (push) Has been cancelled
GitHub CI / Windows x86 Build (push) Has been cancelled
GitHub CI / Upload-Release (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/386) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/amd64) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/arm/v7) (push) Has been cancelled
Publish Docker Image / Build ${{ matrix.platform }} Image (ubuntu-latest, linux/arm64) (push) Has been cancelled
Publish Docker Image / Merge (push) Has been cancelled
This commit is contained in:
commit
f41986f9c9
@ -107,7 +107,7 @@ bool applyMatcher(const std::string &rule, std::string &real_rule, const Proxy &
|
||||
std::string target, ret_real_rule;
|
||||
static const std::string groupid_regex = R"(^!!(?:GROUPID|INSERT)=([\d\-+!,]+)(?:!!(.*))?$)", group_regex = R"(^!!(?:GROUP)=(.+?)(?:!!(.*))?$)";
|
||||
static const std::string type_regex = R"(^!!(?:TYPE)=(.+?)(?:!!(.*))?$)", port_regex = R"(^!!(?:PORT)=(.+?)(?:!!(.*))?$)", server_regex = R"(^!!(?:SERVER)=(.+?)(?:!!(.*))?$)";
|
||||
static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5","VLESS","HYSTERIA","HYSTERIA2"};
|
||||
static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5","VLESS","HYSTERIA","HYSTERIA2","TUIC"};
|
||||
if (startsWith(rule, "!!GROUP=")) {
|
||||
regGetMatch(rule, group_regex, 3, 0, &target, &ret_real_rule);
|
||||
real_rule = ret_real_rule;
|
||||
@ -372,6 +372,37 @@ void proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGr
|
||||
if (!x.OBFSPassword.empty())
|
||||
singleproxy["obfs-password"] = x.OBFSPassword;
|
||||
break;
|
||||
case ProxyType::TUIC:
|
||||
singleproxy["type"] = "tuic";
|
||||
singleproxy["uuid"] = x.Uuid;
|
||||
singleproxy["password"] = x.Password;
|
||||
if (!x.Ip.empty())
|
||||
singleproxy["ip"] = x.Ip;
|
||||
if (!x.Heartbeatinterval.empty())
|
||||
singleproxy["heartbeat-interval"] = x.Heartbeatinterval;
|
||||
if (!x.Disablesni.empty())
|
||||
singleproxy["disable-sni"] = x.Disablesni;
|
||||
if (!x.Reducertt.empty())
|
||||
singleproxy["reduce-rtt"] = x.Reducertt;
|
||||
if (!x.Requesttimeout.empty())
|
||||
singleproxy["request-timeout"] = x.Requesttimeout;
|
||||
if (!x.Udprelaymode.empty())
|
||||
singleproxy["udp-relay-mode"] = x.Udprelaymode;
|
||||
if (!x.Congestioncontroller.empty())
|
||||
singleproxy["congestion-controller"] = x.Congestioncontroller;
|
||||
if (!x.Maxudprelaypacketsize.empty())
|
||||
singleproxy["max-udp-relay-packet-size"] = x.Maxudprelaypacketsize;
|
||||
if (!x.Fastopen.empty())
|
||||
singleproxy["fast-open"] = x.Fastopen;
|
||||
if (!x.Maxopenstreams.empty())
|
||||
singleproxy["max-open-streams"] = x.Maxopenstreams;
|
||||
if (!x.Sni.empty())
|
||||
singleproxy["sni"] = x.Sni;
|
||||
if (!x.Alpn.empty())
|
||||
singleproxy["alpn"].push_back(x.Alpn);
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
break;
|
||||
case ProxyType::VLESS:
|
||||
singleproxy["type"] = "vless";
|
||||
singleproxy["uuid"] = x.UserId;
|
||||
|
@ -16,6 +16,7 @@ enum ProxyType
|
||||
VLESS,
|
||||
Hysteria,
|
||||
Hysteria2,
|
||||
TUIC,
|
||||
Trojan,
|
||||
Snell,
|
||||
HTTP,
|
||||
@ -39,6 +40,8 @@ inline String getProxyTypeName(int type)
|
||||
return "Hysteria";
|
||||
case ProxyType::Hysteria2:
|
||||
return "Hysteria2";
|
||||
case ProxyType::TUIC:
|
||||
return "TUIC";
|
||||
case ProxyType::Trojan:
|
||||
return "Trojan";
|
||||
case ProxyType::Snell:
|
||||
@ -112,6 +115,18 @@ struct Proxy
|
||||
|
||||
String OBFSPassword;
|
||||
|
||||
String Uuid;
|
||||
String Ip;
|
||||
String Heartbeatinterval;
|
||||
String Disablesni;
|
||||
String Reducertt;
|
||||
String Requesttimeout;
|
||||
String Udprelaymode;
|
||||
String Congestioncontroller;
|
||||
String Maxudprelaypacketsize;
|
||||
String Fastopen;
|
||||
String Maxopenstreams;
|
||||
String Sni;
|
||||
};
|
||||
|
||||
#define SS_DEFAULT_GROUP "SSProvider"
|
||||
@ -120,6 +135,7 @@ struct Proxy
|
||||
#define XRAY_DEFAULT_GROUP "XRayProvider"
|
||||
#define HYSTERIA_DEFAULT_GROUP "HysteriaProvider"
|
||||
#define HYSTERIA2_DEFAULT_GROUP "Hysteria2Provider"
|
||||
#define TUIC_DEFAULT_GROUP "TUICProvider"
|
||||
#define SOCKS_DEFAULT_GROUP "SocksProvider"
|
||||
#define HTTP_DEFAULT_GROUP "HTTPProvider"
|
||||
#define TROJAN_DEFAULT_GROUP "TrojanProvider"
|
||||
|
@ -91,6 +91,25 @@ void hysteria2Construct(Proxy &node, const std::string &group, const std::string
|
||||
node.OBFSPassword = obfsPassword;
|
||||
}
|
||||
|
||||
void TUICConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &uuid, const std::string &password, const std::string &ip, const std::string &heartbeatinterval, const std::string &disablesni, const std::string &reducertt, const std::string &requesttimeout, const std::string &udprelaymode, const std::string &congestioncontroller, const std::string &maxudprelaypacketsize, const std::string &fastopen, const std::string &maxopenstreams, const std::string &sni, const std::string &alpn, tribool udp, tribool tfo, tribool scv)
|
||||
{
|
||||
commonConstruct(node, ProxyType::TUIC, group, remarks, add, port, udp, tfo, scv, tribool());
|
||||
node.Password = password;
|
||||
node.Uuid = uuid;
|
||||
node.Ip = ip;
|
||||
node.Heartbeatinterval = heartbeatinterval;
|
||||
node.Disablesni = disablesni;
|
||||
node.Reducertt = reducertt;
|
||||
node.Requesttimeout = requesttimeout;
|
||||
node.Udprelaymode = udprelaymode;
|
||||
node.Congestioncontroller = congestioncontroller;
|
||||
node.Maxudprelaypacketsize = maxudprelaypacketsize;
|
||||
node.Fastopen = fastopen;
|
||||
node.Maxopenstreams = maxopenstreams;
|
||||
node.Sni = sni;
|
||||
node.Alpn = alpn;
|
||||
}
|
||||
|
||||
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &flow, const std::string &mode, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls,const std::string &pbk, const std::string &sid, const std::string &fp ,tribool udp, tribool tfo, tribool scv, tribool tls13)
|
||||
{
|
||||
commonConstruct(node, ProxyType::VLESS, group, remarks, add, port, udp, tfo, scv, tls13);
|
||||
@ -192,7 +211,7 @@ void explodeVless(std::string vless, Proxy &node)
|
||||
|
||||
void explodeHysteria(std::string hysteria, Proxy &node)
|
||||
{
|
||||
printf("explodeHysteria\n");
|
||||
//printf("explodeHysteria\n");
|
||||
if(regMatch(hysteria, "hysteria://(.*?)[:](.*)"))
|
||||
{
|
||||
explodeStdHysteria(hysteria, node);
|
||||
@ -213,6 +232,16 @@ void explodeHysteria2(std::string hysteria2, Proxy &node)
|
||||
}
|
||||
}
|
||||
|
||||
void explodeTUIC(std::string TUIC, Proxy &node)
|
||||
{
|
||||
TUIC = regReplace(TUIC, "/\\?", "?", true, false);
|
||||
if(regMatch(TUIC, "tuic://(.*?)[:](.*)"))
|
||||
{
|
||||
explodeStdTUIC(TUIC, node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void explodeVmess(std::string vmess, Proxy &node)
|
||||
{
|
||||
std::string version, ps, add, port, type, id, aid, net, path, host, tls, sni, alpn;
|
||||
@ -1061,6 +1090,7 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
|
||||
std::string user; //socks
|
||||
std::string auth,up,down,obfsParam,insecure;//hysteria
|
||||
std::string obfsPassword;//hysteria2
|
||||
std::string uuid,ip,heartbeatinterval,disablesni,reducertt,requesttimeout,udprelaymode,congestioncontroller,maxudprelaypacketsize,fastopen,maxopenstreams;//TUIC
|
||||
tribool udp, tfo, scv;
|
||||
Node singleproxy;
|
||||
uint32_t index = nodes.size();
|
||||
@ -1356,6 +1386,26 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
|
||||
scv = singleproxy["insecure"].IsDefined() ? singleproxy["insecure"].as<std::string>() == "1" : false;
|
||||
hysteria2Construct(node, group, ps, server, port, password, host, up, down, alpn, obfsParam, obfsPassword, udp, tfo, scv);
|
||||
break;
|
||||
case "tuic"_hash:
|
||||
group = TUIC_DEFAULT_GROUP;
|
||||
singleproxy["uuid"] >>= uuid;
|
||||
singleproxy["password"] >>= password;
|
||||
singleproxy["ip"] >>= ip;
|
||||
singleproxy["heartbeat-interval"] >>= heartbeatinterval;
|
||||
singleproxy["disable-sni"] >>= disablesni;
|
||||
singleproxy["reduce-rtt"] >>= reducertt;
|
||||
singleproxy["request-timeout"] >>= requesttimeout;
|
||||
singleproxy["udp-relay-mode"] >>= udprelaymode;
|
||||
singleproxy["congestion-controller"] >>= congestioncontroller;
|
||||
singleproxy["max-udp-relay-packet-size"] >>= maxudprelaypacketsize;
|
||||
singleproxy["fast-open"] >>= fastopen;
|
||||
singleproxy["max-open-streams"] >>= maxopenstreams;
|
||||
singleproxy["sni"] >>= sni;
|
||||
singleproxy["alpn"][0] >>= alpn;
|
||||
|
||||
scv = singleproxy["insecure"].IsDefined() ? singleproxy["insecure"].as<std::string>() == "1" : false;
|
||||
TUICConstruct(node, group, ps, server, port, uuid, password, ip, heartbeatinterval, disablesni, reducertt, requesttimeout, udprelaymode, congestioncontroller, maxudprelaypacketsize, fastopen, maxopenstreams, sni, alpn, udp, tfo, scv);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
@ -1498,6 +1548,79 @@ void explodeStdHysteria2(std::string hysteria2, Proxy &node)
|
||||
return;
|
||||
}
|
||||
|
||||
void explodeStdTUIC(std::string TUIC, Proxy &node)
|
||||
{
|
||||
std::string add, port, password, remarks, alpn;
|
||||
std::string uuid,ip,heartbeatinterval,disablesni,reducertt,requesttimeout,udprelaymode,congestioncontroller,maxudprelaypacketsize,fastopen,maxopenstreams,sni;//TUIC
|
||||
|
||||
std::string addition;
|
||||
tribool scv;
|
||||
TUIC = TUIC.substr(7);
|
||||
string_size pos;
|
||||
|
||||
pos = TUIC.rfind("#");
|
||||
if(pos != TUIC.npos)
|
||||
{
|
||||
remarks = urlDecode(TUIC.substr(pos + 1));
|
||||
TUIC.erase(pos);
|
||||
}
|
||||
|
||||
pos = TUIC.rfind("?");
|
||||
if(pos != TUIC.npos)
|
||||
{
|
||||
addition = TUIC.substr(pos + 1);
|
||||
TUIC.erase(pos);
|
||||
}
|
||||
|
||||
if(strFind(TUIC, "@"))
|
||||
{
|
||||
if(regGetMatch(TUIC, R"(^(.*?)@(.*)[:](\d+)$)", 4, 0, &password, &add, &port))
|
||||
return;
|
||||
pos = password.rfind(":");
|
||||
if(pos != password.npos)
|
||||
{
|
||||
uuid = password.substr(pos + 1);
|
||||
password.erase(pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
password = getUrlArg(addition,"password");
|
||||
if(password.empty())
|
||||
return;
|
||||
|
||||
uuid = getUrlArg(addition,"uuid");
|
||||
if(uuid.empty())
|
||||
return;
|
||||
|
||||
if(!strFind(TUIC, ":"))
|
||||
return;
|
||||
|
||||
if(regGetMatch(TUIC, R"(^(.*)[:](\d+)$)", 3, 0, &add, &port))
|
||||
return;
|
||||
}
|
||||
|
||||
scv = getUrlArg(addition, "insecure");
|
||||
ip = getUrlArg(addition,"ip");
|
||||
heartbeatinterval = getUrlArg(addition,"heartbeat_interval");
|
||||
disablesni = getUrlArg(addition,"disable_sni");
|
||||
reducertt = getUrlArg(addition,"reduce_rtt");
|
||||
requesttimeout = getUrlArg(addition,"request_timeout");
|
||||
udprelaymode = getUrlArg(addition,"udp_relay_mode");
|
||||
congestioncontroller = getUrlArg(addition,"congestion_control");
|
||||
maxudprelaypacketsize = getUrlArg(addition,"max_udp_relay_packet_size");
|
||||
fastopen = getUrlArg(addition,"fast_open");
|
||||
maxopenstreams = getUrlArg(addition,"max_open_streams");
|
||||
sni = getUrlArg(addition,"sni");
|
||||
alpn = getUrlArg(addition,"alpn");
|
||||
|
||||
if(remarks.empty())
|
||||
remarks = add + ":" + port;
|
||||
|
||||
TUICConstruct(node, TUIC_DEFAULT_GROUP, remarks, add, port, uuid, password, ip, heartbeatinterval, disablesni, reducertt, requesttimeout, udprelaymode, congestioncontroller, maxudprelaypacketsize, fastopen, maxopenstreams, sni, alpn, tribool(), tribool(), scv);
|
||||
return;
|
||||
}
|
||||
|
||||
void explodeStdVless(std::string vless, Proxy &node)
|
||||
{
|
||||
std::string add, port, type, id, aid, net, flow, pbk, sid, fp, mode, path, host, tls, remarks;
|
||||
@ -2431,6 +2554,8 @@ void explode(const std::string &link, Proxy &node)
|
||||
explodeHysteria(link, node);
|
||||
else if(strFind(link, "hysteria2://") || strFind(link, "hy2://"))
|
||||
explodeHysteria2(link, node);
|
||||
else if(strFind(link, "tuic://"))
|
||||
explodeTUIC(link, node);
|
||||
else if(strFind(link, "ss://"))
|
||||
explodeSS(link, node);
|
||||
else if(strFind(link, "socks://") || strFind(link, "https://t.me/socks") || strFind(link, "tg://socks"))
|
||||
|
@ -22,6 +22,7 @@ enum class ConfType
|
||||
|
||||
void hysteriaConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &auth, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &insecure ,tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void hysteria2Construct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &password, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &obfsPassword, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
void TUICConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &uuid, const std::string &password, const std::string &ip, const std::string &heartbeatinterval, const std::string &disablesni, const std::string &reducertt, const std::string &requesttimeout, const std::string &udprelaymode, const std::string &congestioncontroller, const std::string &maxudprelaypacketsize, const std::string &fastopen, const std::string &maxopenstreams, const std::string &sni, const std::string &alpn, tribool udp, tribool tfo, tribool scv);
|
||||
void vmessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, const std::string &sni, const std::string &alpn, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &flow, const std::string &mode, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls,const std::string &pkd, const std::string &sid, const std::string &fp, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void ssrConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &protocol, const std::string &method, const std::string &obfs, const std::string &password, const std::string &obfsparam, const std::string &protoparam, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
@ -34,6 +35,7 @@ void explodeVmess(std::string vmess, Proxy &node);
|
||||
void explodeVless(std::string vless, Proxy &node);
|
||||
void explodeHysteria(std::string hysteria, Proxy &node);
|
||||
void explodeHysteria2(std::string hysteria2, Proxy &node);
|
||||
void explodeTUIC(std::string TUIC, Proxy &node);
|
||||
void explodeSSR(std::string ssr, Proxy &node);
|
||||
void explodeSS(std::string ss, Proxy &node);
|
||||
void explodeTrojan(std::string trojan, Proxy &node);
|
||||
@ -42,6 +44,7 @@ void explodeStdVMess(std::string vmess, Proxy &node);
|
||||
void explodeStdVless(std::string vless, Proxy &node);
|
||||
void explodeStdHysteria(std::string hysteria, Proxy &node);
|
||||
void explodeStdHysteria2(std::string hysteria2, Proxy &node);
|
||||
void explodeStdTUIC(std::string TUIC, Proxy &node);
|
||||
void explodeShadowrocket(std::string kit, Proxy &node);
|
||||
void explodeKitsunebi(std::string kit, Proxy &node);
|
||||
/// Parse a link
|
||||
|
Loading…
Reference in New Issue
Block a user