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
4 changed files with 23 additions and 3 deletions

View File

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

View File

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

View File

@@ -102,7 +102,7 @@ export default function URI_Producer() {
port: proxy.port,
id: proxy.uuid,
type,
aid: 0,
aid: proxy.alterId || 0,
net,
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}:${
proxy.port
}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${
proxy['skip-cert-verify'] ? '&allowInsecure=1' : ''
}${trojanTransport}#${encodeURIComponent(proxy.name)}`;
}${trojanTransport}${trojanAlpn}${trojanFp}#${encodeURIComponent(
proxy.name,
)}`;
break;
case 'hysteria2':
let hysteria2params = [];