diff --git a/backend/package.json b/backend/package.json index d6fcba00..cbb0c89d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.82", + "version": "2.21.83", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/index.js b/backend/src/core/proxy-utils/index.js index d1789701..575f0715 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -88,6 +88,13 @@ function parse(raw) { $.info(`UUID may be invalid: ${proxy.name} ${proxy.uuid}`); } // return isProxyUUIDValid; + } else if (['hysteria2'].includes(proxy.type)) { + if (proxy.obfs && !proxy['obfs-password']) { + $.error( + `Proxy ${proxy.name} has obfs ${proxy.obfs} but missing obfs-password`, + ); + return false; + } } return true; }); diff --git a/backend/src/test/proxy-parsers/uri.spec.js b/backend/src/test/proxy-parsers/uri.spec.js index 2557eb51..3a892322 100644 --- a/backend/src/test/proxy-parsers/uri.spec.js +++ b/backend/src/test/proxy-parsers/uri.spec.js @@ -2,7 +2,7 @@ import { Base64 } from 'js-base64'; import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { UUID, parseOne, expectSubset } from './helpers'; +import { UUID, parseAll, parseOne, expectSubset } from './helpers'; describe('Proxy URI parser coverage', function () { describe('generic URIs', function () { @@ -297,6 +297,14 @@ describe('Proxy URI parser coverage', function () { }); }); + it('rejects Hysteria2 salamander obfs without obfs-password', function () { + const proxies = parseAll( + 'hy2://hy2-secret@hy2.example.com:443?obfs=salamander#Hy2%20Missing%20Password', + ); + + expect(proxies).to.deep.equal([]); + }); + it('parses TUIC URIs with colon-containing passwords and booleans', function () { const proxy = parseOne( `tuic://${UUID}:pass%3Aword@tuic.example.com?alpn=h3,hq-29&allow-insecure=1&fast-open=1&disable-sni=1&reduce-rtt=1&congestion-control=bbr#TUIC`,