feat: converter support REALITY share standard

This commit is contained in:
metacubex 2023-03-22 17:09:55 +08:00
parent 2d82eb7844
commit b44610fb3d
4 changed files with 17 additions and 4 deletions

View File

@ -226,6 +226,11 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
singleproxy["name"] = remark;
singleproxy["server"] = x.Hostname;
singleproxy["port"] = x.Port;
if (!x.PublicKey.empty()){
singleproxy["reality-opts"]["public-key"] = x.PublicKey;
if (!x.ShortId.empty())
singleproxy["reality-opts"]["short-id"] = x.ShortId;
}
switch (x.Type) {
case ProxyType::Shadowsocks:

View File

@ -102,6 +102,10 @@ struct Proxy
String UpMbps;
String DownMbps;
String Insecure;
String PublicKey;
String ShortId;
};
#define SS_DEFAULT_GROUP "SSProvider"

View File

@ -79,7 +79,7 @@ void hysteriaConstruct(Proxy &node, const std::string &group, const std::string
node.FakeType = type;
}
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, tribool udp, tribool tfo, tribool scv, tribool tls13)
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 ,tribool udp, tribool tfo, tribool scv, tribool tls13)
{
commonConstruct(node, ProxyType::VLESS, group, remarks, add, port, udp, tfo, scv, tls13);
node.UserId = id.empty() ? "00000000-0000-0000-0000-000000000000" : id;
@ -90,6 +90,8 @@ void vlessConstruct(Proxy &node, const std::string &group, const std::string &re
node.Flow = flow;
node.FakeType = type;
node.TLSSecure = tls == "tls" || tls == "xtls";
node.PublicKey = pkd;
node.ShortId = sid;
switch(hash_(net))
{
@ -1318,7 +1320,7 @@ void explodeStdHysteria(std::string hysteria, Proxy &node)
void explodeStdVless(std::string vless, Proxy &node)
{
std::string add, port, type, id, aid, net, flow, mode, path, host, tls, remarks;
std::string add, port, type, id, aid, net, flow, pbk,sid,mode, path, host, tls, remarks;
std::string addition;
vless = vless.substr(8);
string_size pos;
@ -1336,6 +1338,8 @@ void explodeStdVless(std::string vless, Proxy &node)
tls = getUrlArg(addition,"security");
net = getUrlArg(addition,"type");
flow = getUrlArg(addition,"flow");
pbk = getUrlArg(addition,"pbk");
sid = getUrlArg(addition,"sid");
switch(hash_(net))
{
@ -1363,7 +1367,7 @@ void explodeStdVless(std::string vless, Proxy &node)
if(remarks.empty())
remarks = add + ":" + port;
vlessConstruct(node, XRAY_DEFAULT_GROUP, remarks, add, port, type, id, aid, net, "auto", flow, mode, path, host, "", tls);
vlessConstruct(node, XRAY_DEFAULT_GROUP, remarks, add, port, type, id, aid, net, "auto", flow, mode, path, host, "", tls,pbk,sid);
return;
}

View File

@ -22,7 +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 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, 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, 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());
void ssConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
void socksConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());