diff --git a/backend/package.json b/backend/package.json index e8ba6763..2fc1fba9 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.38.2", + "version": "2.38.3", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "packageManager": "pnpm@11.0.9", @@ -62,4 +62,4 @@ "peggy": "^2.0.1", "prettier": "2.6.2" } -} +} \ No newline at end of file diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index 0e968686..45c5ea59 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -596,7 +596,9 @@ function URI_SSR() { ? Base64.decode(other_params.remarks) : proxy.server, 'protocol-param': getIfNotBlank( - Base64.decode(other_params.protoparam || '').replace(/\s/g, ''), + Base64.decode( + other_params.protoparam || other_params.protocolparam || '', + ).replace(/\s/g, ''), ), 'obfs-param': getIfNotBlank( Base64.decode(other_params.obfsparam || '').replace(/\s/g, ''), diff --git a/backend/src/core/proxy-utils/producers/uri.js b/backend/src/core/proxy-utils/producers/uri.js index f9e6456a..2966ef9f 100644 --- a/backend/src/core/proxy-utils/producers/uri.js +++ b/backend/src/core/proxy-utils/producers/uri.js @@ -1013,7 +1013,7 @@ export default function URI_Producer() { : '' }${ proxy['protocol-param'] - ? '&protocolparam=' + + ? '&protoparam=' + Base64.encode(proxy['protocol-param']) : '' }`; diff --git a/backend/src/test/proxy-producers/text.spec.js b/backend/src/test/proxy-producers/text.spec.js index 662f2742..3990ef00 100644 --- a/backend/src/test/proxy-producers/text.spec.js +++ b/backend/src/test/proxy-producers/text.spec.js @@ -2268,6 +2268,36 @@ describe('Proxy text producers', function () { expect(defaults).to.not.include('ipv6-cidr='); }); + it('normalizes SSR protocol parameter aliases and preserves them on URI round-trips', function () { + const canonical = Base64.encode('user:pass'); + const legacy = Base64.encode('legacy:pass'); + + for (const [query, expected] of [ + [`protoparam=${canonical}`, 'user:pass'], + [`protocolparam=${legacy}`, 'legacy:pass'], + [`protoparam=${canonical}&protocolparam=${legacy}`, 'user:pass'], + [`protocolparam=${legacy}&protoparam=${canonical}`, 'user:pass'], + [`protoparam=&protocolparam=${legacy}`, 'legacy:pass'], + ]) { + const input = `ssr://${Base64.encode( + `ssr.example.com:8899:auth_aes128_md5:aes-256-cfb:plain:${Base64.encode( + 'secret', + )}/?remarks=${Base64.encode('SSR')}&${query}`, + )}`; + const [proxy] = ProxyUtils.parse(input); + expect(proxy['protocol-param'], query).to.equal(expected); + + const output = produceExternal('URI', proxy); + const decoded = Base64.decode(output.slice(6)); + expect(decoded, query).to.include( + `&protoparam=${Base64.encode(expected)}`, + ); + expect(decoded, query).not.to.include('&protocolparam='); + const [reparsed] = ProxyUtils.parse(output); + expect(reparsed['protocol-param'], query).to.equal(expected); + } + }); + it('produces URI shadowsocks links with v2ray-plugin mux and tls flags', function () { const plugin = encodeURIComponent( 'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;sni=sni.example.com;skip-cert-verify=true;mux=0',