Skip to content

Commit 3588358

Browse files
committed
feat: 优化 VMess URI 转换
1 parent 360ad5b commit 3588358

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.23.28",
3+
"version": "2.23.29",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"packageManager": "pnpm@11.0.9",

backend/src/core/proxy-utils/producers/uri.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ function getTransportHost(network, transportOpts = {}) {
131131
);
132132
}
133133

134+
function normalizeVmessSecurity(security) {
135+
if (
136+
security &&
137+
![
138+
'aes-128-gcm',
139+
'chacha20-poly1305',
140+
'auto',
141+
'none',
142+
'zero',
143+
].includes(security)
144+
) {
145+
return 'auto';
146+
}
147+
148+
return security;
149+
}
150+
134151
function mapReuseSettingsToXmux(reuseSettings) {
135152
if (!isPlainObject(reuseSettings)) {
136153
return undefined;
@@ -997,7 +1014,7 @@ export default function URI_Producer() {
9971014
port: `${proxy.port}`,
9981015
id: proxy.uuid,
9991016
aid: `${proxy.alterId || 0}`,
1000-
scy: proxy.cipher,
1017+
scy: normalizeVmessSecurity(proxy.cipher),
10011018
net,
10021019
type,
10031020
tls: proxy.tls ? 'tls' : '',

backend/src/test/proxy-producers/text.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,25 @@ describe('Proxy text producers', function () {
19911991
);
19921992
});
19931993

1994+
it('normalizes unsupported URI VMess scy values to auto', function () {
1995+
const output = produceExternal('URI', {
1996+
type: 'vmess',
1997+
name: 'URI VMess Invalid Security',
1998+
server: 'vmess-invalid.example.com',
1999+
port: 443,
2000+
uuid: UUID,
2001+
cipher: 'aes-128-ctr',
2002+
alterId: 0,
2003+
tls: true,
2004+
network: 'ws',
2005+
});
2006+
const payload = JSON.parse(
2007+
Base64.decode(output.replace(/^vmess:\/\//, '')),
2008+
);
2009+
2010+
expect(payload.scy).to.equal('auto');
2011+
});
2012+
19942013
it('produces URI VMess h2 links from mihomo h2-opts host', function () {
19952014
const output = produceExternal('URI', {
19962015
type: 'vmess',

0 commit comments

Comments
 (0)