diff --git a/backend/package.json b/backend/package.json index 4c1f3eab5..16f418a3b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.442", + "version": "2.14.443", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index 5744e7c48..b049320dd 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -46,9 +46,15 @@ function URI_SS() { content = content.split('#')[0]; // strip proxy name // handle IPV4 and IPV6 let serverAndPortArray = content.match(/@([^/]*)(\/|$)/); - let userInfoStr = Base64.decode( - decodeURIComponent(content.split('@')[0]), - ); + + let rawUserInfoStr = decodeURIComponent(content.split('@')[0]); // 其实应该分隔之后, 用户名和密码再 decodeURIComponent. 但是问题不大 + let userInfoStr; + if (rawUserInfoStr?.startsWith('2022-blake3-')) { + userInfoStr = rawUserInfoStr; + } else { + userInfoStr = Base64.decode(rawUserInfoStr); + } + let query = ''; if (!serverAndPortArray) { if (content.includes('?')) { @@ -73,15 +79,21 @@ function URI_SS() { userInfoStr = content.split('@')[0]; serverAndPortArray = content.match(/@([^/]*)(\/|$)/); } + const serverAndPort = serverAndPortArray[1]; const portIdx = serverAndPort.lastIndexOf(':'); proxy.server = serverAndPort.substring(0, portIdx); proxy.port = `${serverAndPort.substring(portIdx + 1)}`.match( /\d+/, )?.[0]; - const userInfo = userInfoStr.match(/(^.*?):(.*$)/); - proxy.cipher = userInfo[1]; - proxy.password = userInfo[2]; + let userInfo = userInfoStr.match(/(^.*?):(.*$)/); + proxy.cipher = userInfo?.[1]; + proxy.password = userInfo?.[2]; + // if (!proxy.cipher || !proxy.password) { + // userInfo = rawUserInfoStr.match(/(^.*?):(.*$)/); + // proxy.cipher = userInfo?.[1]; + // proxy.password = userInfo?.[2]; + // } // handle obfs const idx = content.indexOf('?plugin='); diff --git a/backend/src/core/proxy-utils/producers/uri.js b/backend/src/core/proxy-utils/producers/uri.js index 1231ab311..564c1dccb 100644 --- a/backend/src/core/proxy-utils/producers/uri.js +++ b/backend/src/core/proxy-utils/producers/uri.js @@ -29,9 +29,13 @@ export default function URI_Producer() { switch (proxy.type) { case 'ss': const userinfo = `${proxy.cipher}:${proxy.password}`; - result = `ss://${Base64.encode(userinfo)}@${proxy.server}:${ - proxy.port - }${proxy.plugin ? '/' : ''}`; + result = `ss://${ + proxy.cipher?.startsWith('2022-blake3-') + ? `${encodeURIComponent( + proxy.cipher, + )}:${encodeURIComponent(proxy.password)}` + : Base64.encode(userinfo) + }@${proxy.server}:${proxy.port}${proxy.plugin ? '/' : ''}`; if (proxy.plugin) { result += '?plugin='; const opts = proxy['plugin-opts'];