feat: VMess URI 输出支持 alterId; Trojan 支持 fp 和 alpn

This commit is contained in:
xream 2024-11-28 16:04:52 +08:00
parent 815552d470
commit 8d0a71d983
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
4 changed files with 23 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.430", "version": "2.14.431",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -82,6 +82,8 @@ port = digits:[0-9]+ {
params = "?" head:param tail:("&"@param)* { params = "?" head:param tail:("&"@param)* {
proxy["skip-cert-verify"] = toBool(params["allowInsecure"]); proxy["skip-cert-verify"] = toBool(params["allowInsecure"]);
proxy.sni = params["sni"] || params["peer"]; proxy.sni = params["sni"] || params["peer"];
proxy['client-fingerprint'] = params.fp;
proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(',') : undefined;
if (toBool(params["ws"])) { if (toBool(params["ws"])) {
proxy.network = "ws"; proxy.network = "ws";

View File

@ -80,6 +80,8 @@ port = digits:[0-9]+ {
params = "?" head:param tail:("&"@param)* { params = "?" head:param tail:("&"@param)* {
proxy["skip-cert-verify"] = toBool(params["allowInsecure"]); proxy["skip-cert-verify"] = toBool(params["allowInsecure"]);
proxy.sni = params["sni"] || params["peer"]; proxy.sni = params["sni"] || params["peer"];
proxy['client-fingerprint'] = params.fp;
proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(',') : undefined;
if (toBool(params["ws"])) { if (toBool(params["ws"])) {
proxy.network = "ws"; proxy.network = "ws";

View File

@ -102,7 +102,7 @@ export default function URI_Producer() {
port: proxy.port, port: proxy.port,
id: proxy.uuid, id: proxy.uuid,
type, type,
aid: 0, aid: proxy.alterId || 0,
net, net,
tls: proxy.tls ? 'tls' : '', tls: proxy.tls ? 'tls' : '',
}; };
@ -290,11 +290,27 @@ export default function URI_Producer() {
)}`; )}`;
} }
} }
let trojanFp = '';
if (proxy['client-fingerprint']) {
trojanFp = `&fp=${encodeURIComponent(
proxy['client-fingerprint'],
)}`;
}
let trojanAlpn = '';
if (proxy.alpn) {
trojanAlpn = `&alpn=${encodeURIComponent(
Array.isArray(proxy.alpn)
? proxy.alpn
: proxy.alpn.join(','),
)}`;
}
result = `trojan://${proxy.password}@${proxy.server}:${ result = `trojan://${proxy.password}@${proxy.server}:${
proxy.port proxy.port
}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${ }?sni=${encodeURIComponent(proxy.sni || proxy.server)}${
proxy['skip-cert-verify'] ? '&allowInsecure=1' : '' proxy['skip-cert-verify'] ? '&allowInsecure=1' : ''
}${trojanTransport}#${encodeURIComponent(proxy.name)}`; }${trojanTransport}${trojanAlpn}${trojanFp}#${encodeURIComponent(
proxy.name,
)}`;
break; break;
case 'hysteria2': case 'hysteria2':
let hysteria2params = []; let hysteria2params = [];