From f069fbb347df2243bdb916685bc120e498e68a7c Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 17 May 2026 22:36:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Egern=20Hysteria=202=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20bandwidth;=20Hysteria=202=20URI=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=A7=A3=E6=9E=90=20upmbps=20=E5=92=8C=20downmbps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/parsers/index.js | 6 ++++ .../src/core/proxy-utils/producers/egern.js | 8 ++++++ backend/src/test/proxy-parsers/uri.spec.js | 16 +++++++++++ .../test/proxy-producers/structured.spec.js | 28 +++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index c6f6824f..67e0ef12 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.23.10", + "version": "2.23.11", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "packageManager": "pnpm@11.0.9", diff --git a/backend/src/core/proxy-utils/parsers/index.js b/backend/src/core/proxy-utils/parsers/index.js index 8b92a68a..6d3badf6 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -2104,6 +2104,12 @@ function URI_Hysteria2() { if (/^\d+$/.test(keepalive)) { proxy['keepalive'] = parseInt(`${keepalive}`, 10); } + if (params.upmbps) { + proxy.up = params.upmbps; + } + if (params.downmbps) { + proxy.down = params.downmbps; + } return proxy; }; diff --git a/backend/src/core/proxy-utils/producers/egern.js b/backend/src/core/proxy-utils/producers/egern.js index b6e248c7..487f404b 100644 --- a/backend/src/core/proxy-utils/producers/egern.js +++ b/backend/src/core/proxy-utils/producers/egern.js @@ -181,6 +181,14 @@ export default function Egern_Producer() { server: proxy.server, port: proxy.port, auth: proxy.password, + ...(isPresent(proxy, 'up') + ? { + bandwidth: parseInt( + `${proxy.up}`.match(/\d+/)?.[0] || 0, + 10, + ), + } + : {}), tfo: proxy.tfo || proxy['fast-open'], udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay, diff --git a/backend/src/test/proxy-parsers/uri.spec.js b/backend/src/test/proxy-parsers/uri.spec.js index b35206cd..07a02a4b 100644 --- a/backend/src/test/proxy-parsers/uri.spec.js +++ b/backend/src/test/proxy-parsers/uri.spec.js @@ -496,6 +496,22 @@ describe('Proxy URI parser coverage', function () { }); }); + it('parses Hysteria2 URI throughput fields', function () { + const proxy = parseOne( + 'hy2://hy2-secret@hy2.example.com:443?upmbps=50&downmbps=100#Hy2%20Throughput', + ); + + expectSubset(proxy, { + type: 'hysteria2', + name: 'Hy2 Throughput', + server: 'hy2.example.com', + port: 443, + password: 'hy2-secret', + up: '50', + down: '100', + }); + }); + it('rejects Hysteria2 salamander obfs without obfs-password', function () { const proxies = parseAll( 'hy2://hy2-secret@hy2.example.com:443?obfs=salamander#Hy2%20Missing%20Password', diff --git a/backend/src/test/proxy-producers/structured.spec.js b/backend/src/test/proxy-producers/structured.spec.js index ee40ae92..f55bc8ff 100644 --- a/backend/src/test/proxy-producers/structured.spec.js +++ b/backend/src/test/proxy-producers/structured.spec.js @@ -1341,6 +1341,34 @@ describe('Proxy structured producers', function () { }); }); + it('emits Egern Hysteria2 upload bandwidth as bandwidth', function () { + const proxy = { + type: 'hysteria2', + name: 'Egern Hysteria2 Bandwidth', + server: 'hy2.example.com', + port: 443, + password: 'secret', + up: '50 Mbps', + sni: 'peer.example.com', + }; + + const internal = produceInternal('Egern', proxy)[0]; + const external = loadProducedYaml('Egern', proxy); + + expectSubset(internal, { + hysteria2: { + name: 'Egern Hysteria2 Bandwidth', + bandwidth: 50, + }, + }); + expectSubset(external.proxies[0], { + hysteria2: { + name: 'Egern Hysteria2 Bandwidth', + bandwidth: 50, + }, + }); + }); + it('keeps Mihomo HTTP headers and filters unsupported h2-connect/trusttunnel header variants', function () { const { result, errors } = captureErrors(() => produceInternal('Mihomo', [