feat: 支持更多的 Shadowrocket 非标 VLESS URI
build / build (push) Canceled after 0s

This commit is contained in:
xream committed 2026-12-03 01:21:05 +08:00
1 parent 7a7fcb38eb
commit 1028246d72
3 files changed
+44 -15

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.44.37",
"version": "2.44.38",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"packageManager": "pnpm@11.0.9",
+18 -14
View File
@@ -1836,18 +1836,17 @@ function URI_VLESS() {
};
line = line.split(`${protocol}://`)[1];
let isShadowrocket;
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
if (!parsed) {
const hasBase64Address = !parsed;
if (hasBase64Address) {
// eslint-disable-next-line no-unused-vars
let [_, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
line = `${Base64.decode(base64)}${other}`;
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
isShadowrocket = true;
}
// eslint-disable-next-line no-unused-vars
let [__, uuid, server, port, ___, addons = '', name] = parsed;
if (isShadowrocket) {
if (hasBase64Address) {
uuid = uuid.replace(/^.*?:/g, '');
}
@@ -1879,17 +1878,20 @@ function URI_VLESS() {
params.remark ??
`${protocol === 'vmess' ? 'VMess' : 'VLESS'} ${server}:${port}`;
const legacyTLS = /TRUE|1/i.test(params.tls);
proxy.tls = params.security && params.security !== 'none';
if (params.pbk) {
params.security = 'reality';
}
if (isShadowrocket && /TRUE|1/i.test(params.tls)) {
if (legacyTLS && (hasBase64Address || params.security == null)) {
proxy.tls = true;
params.security = params.security ?? 'reality';
}
if (
params.pbk ||
(hasBase64Address && legacyTLS && params.security == null)
) {
params.security = 'reality';
}
proxy.sni = params.sni || params.peer;
proxy.flow = params.flow;
if (!proxy.flow && isShadowrocket && params.xtls) {
if (!proxy.flow && params.xtls) {
// "none" is undefined
const flow = [undefined, 'xtls-rprx-direct', 'xtls-rprx-vision'][
params.xtls
@@ -1898,7 +1900,8 @@ function URI_VLESS() {
proxy.flow = flow;
}
}
proxy['client-fingerprint'] = params.fp ?? params['client-fingerprint'];
proxy['client-fingerprint'] =
params.fp ?? params['client-fingerprint'] ?? params.fingerprint;
proxy.alpn = params.alpn ? params.alpn.split(',') : undefined;
proxy['skip-cert-verify'] =
/(TRUE)|1/i.test(params.allowInsecure) ||
@@ -1962,8 +1965,9 @@ function URI_VLESS() {
proxy.network = 'ws';
httpupgrade = true;
}
if (!params.type && isShadowrocket && params.obfs) {
proxy.network = params.obfs;
const legacyObfs = !params.type && params.obfs;
if (legacyObfs) {
proxy.network = legacyObfs;
if (['none'].includes(proxy.network)) {
proxy.network = 'tcp';
}
@@ -2008,7 +2012,7 @@ function URI_VLESS() {
}
if (params.serviceName) {
opts[`${proxy.network}-service-name`] = params.serviceName;
} else if (isShadowrocket && params.path) {
} else if ((hasBase64Address || legacyObfs) && params.path) {
if (!['ws', 'http', 'h2', 'xhttp'].includes(proxy.network)) {
opts[`${proxy.network}-service-name`] = params.path;
delete params.path;
@@ -2532,6 +2532,31 @@ describe('VMess and VLESS parser coverage', function () {
},
});
});
it('parses Shadowrocket VLESS shares with a plain address', function () {
const proxy = parseOne(
`vless://${UUID}@shadowrocket-vless.example.com:443?obfs=websocket&obfsParam=ws.shadow.example.com&path=/shadow&remarks=Shadowrocket%20VLESS&tls=1&peer=sni.shadow.example.com&udp=1&fingerprint=safari`,
);
expectSubset(proxy, {
type: 'vless',
name: 'Shadowrocket VLESS',
server: 'shadowrocket-vless.example.com',
port: 443,
uuid: UUID,
tls: true,
sni: 'sni.shadow.example.com',
udp: true,
'client-fingerprint': 'safari',
network: 'ws',
'ws-opts': {
path: '/shadow',
headers: {
Host: 'ws.shadow.example.com',
},
},
});
});
});
});