Skip to content

Commit 3f50ea3

Browse files
authored
Merge pull request #37 from W-Webber/feature-quanx-vless
feat(QuanX): 新增Quantumult X对vless及reality协议的支持
2 parents 06427a3 + 1a8cd62 commit 3f50ea3

File tree

2 files changed

+76
-4
lines changed

2 files changed

+76
-4
lines changed

src/generator/config/subexport.cpp

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<Ruleset
16371637

16381638
processRemark(x.Remark, remarks_list);
16391639

1640-
std::string &hostname = x.Hostname, &method = x.EncryptMethod, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &path = x.Path, &password = x.Password, &plugin = x.Plugin, &pluginopts = x.PluginOption, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &username = x.Username;
1640+
std::string &hostname = x.Hostname, &method = x.EncryptMethod, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &path = x.Path, &password = x.Password, &plugin = x.Plugin, &pluginopts = x.PluginOption, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &username = x.Username, &uuid = x.UUID, &sni = x.SNI, &publickey = x.PublicKey, &shortid = x.ShortID, &flow = x.Flow;
16411641
std::string port = std::to_string(x.Port);
16421642
bool &tlssecure = x.TLSSecure;
16431643

@@ -1756,6 +1756,75 @@ void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<Ruleset
17561756
proxyStr += ", over-tls=false";
17571757
}
17581758
}
1759+
break;
1760+
case ProxyType::VLESS:
1761+
method = "none";
1762+
proxyStr = "vless = " + hostname + ":" + port + ", method=" + method + ", password=" + uuid;
1763+
if(tlssecure && !tls13.is_undef())
1764+
proxyStr += ", tls13=" + std::string(tls13 ? "true" : "false");
1765+
if(transproto == "ws")
1766+
{
1767+
if(tlssecure)
1768+
proxyStr += ", obfs=wss";
1769+
else
1770+
proxyStr += ", obfs=ws";
1771+
1772+
if(tlssecure && !publickey.empty() && sni.empty())
1773+
writeLog(0, "Quantumult X vless reality: public key present but SNI missing; skipping reality output.", LOG_LEVEL_WARNING);
1774+
if(tlssecure && !shortid.empty() && publickey.empty())
1775+
writeLog(0, "Quantumult X vless reality: shortid present but public key missing; skipping reality output.", LOG_LEVEL_WARNING);
1776+
1777+
if(tlssecure && !publickey.empty() && !sni.empty())
1778+
proxyStr += ", obfs-host=" + sni;
1779+
else if(!host.empty())
1780+
proxyStr += ", obfs-host=" + host;
1781+
1782+
if(!path.empty())
1783+
proxyStr += ", obfs-uri=" + path;
1784+
1785+
if(tlssecure && !publickey.empty() && !sni.empty())
1786+
{
1787+
proxyStr += ", reality-base64-pubkey=" + publickey;
1788+
if(!shortid.empty())
1789+
proxyStr += ", reality-hex-shortid=" + shortid;
1790+
}
1791+
}
1792+
else if(transproto == "http")
1793+
{
1794+
proxyStr += ", obfs=http";
1795+
if(!host.empty())
1796+
proxyStr += ", obfs-host=" + host;
1797+
if(!path.empty())
1798+
proxyStr += ", obfs-uri=" + path;
1799+
}
1800+
else if(transproto == "tcp")
1801+
{
1802+
if(tlssecure){
1803+
proxyStr += ", obfs=over-tls";
1804+
1805+
if(!publickey.empty() && sni.empty())
1806+
writeLog(0, "Quantumult X vless reality: public key present but SNI missing; skipping reality output.", LOG_LEVEL_WARNING);
1807+
if(!shortid.empty() && publickey.empty())
1808+
writeLog(0, "Quantumult X vless reality: shortid present but public key missing; skipping reality output.", LOG_LEVEL_WARNING);
1809+
1810+
if(!publickey.empty() && !sni.empty()){
1811+
proxyStr += ", obfs-host=" + sni;
1812+
proxyStr += ", reality-base64-pubkey=" + publickey;
1813+
if(!shortid.empty())
1814+
proxyStr += ", reality-hex-shortid=" + shortid;
1815+
if(!flow.empty())
1816+
proxyStr += ", vless-flow=" + flow;
1817+
}
1818+
1819+
}
1820+
}
1821+
else if(tlssecure)
1822+
{
1823+
proxyStr += ", obfs=over-tls";
1824+
if(!sni.empty())
1825+
proxyStr += ", obfs-host=" + sni;
1826+
}
1827+
17591828
break;
17601829
default:
17611830
continue;

src/parser/subparser.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,8 +1406,10 @@ void explodeClash(Node yamlnode, std::vector<Proxy> &nodes)
14061406
singleproxy["path"] >>= path;
14071407
break;
14081408
}
1409-
vlessConstruct(node, group, ps, server, port, uuid, sni, alpn, type, net, mode, host, path, fingerprint, flow, xtls, public_key, short_id, client_fingerprint, udp, tfo, scv, underlying_proxy);
1409+
tls = safe_as<std::string>(singleproxy["tls"]) == "true" ? "tls" : "";
14101410

1411+
vlessConstruct(node, group, ps, server, port, uuid, sni, alpn, type, net, mode, host, path, fingerprint, flow, xtls, public_key, short_id, client_fingerprint, udp, tfo, scv, underlying_proxy);
1412+
node.TLSSecure = tls == "tls";
14111413
// Assign new parameters to node for VLESS
14121414
node.IpVersion = ip_version;
14131415
node.EchEnable = ech_enable;
@@ -2124,7 +2126,7 @@ void explodeAnyTLS(std::string anytls, Proxy &node) {
21242126
}
21252127

21262128
void explodeStdVLESS(std::string vless, Proxy &node) {
2127-
std::string add, port, uuid, sni, alpn, net, type, mode, host, path, fingerprint, remarks, addition, flow, xtls, public_key, short_id;
2129+
std::string add, port, uuid, sni, alpn, net, type, mode, host, path, fingerprint, remarks, addition, flow, xtls, public_key, short_id, security, tls;
21282130
tribool tfo, scv;
21292131
std::string decoded, userinfo, hostinfo;
21302132
string_array user_parts;
@@ -2185,6 +2187,7 @@ void explodeStdVLESS(std::string vless, Proxy &node) {
21852187
flow = getUrlArg(addition, "flow");
21862188
xtls = getUrlArg(addition, "xtls");
21872189
public_key = getUrlArg(addition, "pbk");
2190+
security = getUrlArg(addition, "security");
21882191
short_id = getUrlArg(addition, "sid");
21892192
tfo = tribool(getUrlArg(addition, "tfo"));
21902193
std::string insecure_val = getUrlArg(addition, "insecure");
@@ -2224,7 +2227,7 @@ void explodeStdVLESS(std::string vless, Proxy &node) {
22242227

22252228
if (remarks.empty())
22262229
remarks = add + ":" + port;
2227-
2230+
node.TLSSecure = security == "tls" || security == "reality";
22282231
vlessConstruct(node, VLESS_DEFAULT_GROUP, remarks, add, port, uuid, sni, alpn, type, net, mode, host, path, fingerprint, flow, xtls, public_key, short_id, "", tribool(), tfo, scv, "");
22292232
}
22302233

0 commit comments

Comments
 (0)