From cef931fa5d4d4c08d95e93032d46e7d4b65f4c04 Mon Sep 17 00:00:00 2001 From: xream Date: Mon, 10 Mar 2025 19:52:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Hysteria2=20URI=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=94=AF=E6=8C=81=20hop-interval=20=E5=92=8C?= =?UTF-8?q?=20keepalive=20=E5=8F=82=E6=95=B0,=20=E4=B8=BA=E4=BF=9D?= =?UTF-8?q?=E8=AF=81=E5=85=BC=E5=AE=B9=E6=80=A7,=20=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E5=A4=9A=E7=AB=AF=E5=8F=A3=E6=9A=82=E6=97=B6=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=BD=BF=E7=94=A8=20mport=20=E5=8F=82=E6=95=B0?= 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 | 16 ++++++++++++++-- backend/src/core/proxy-utils/producers/uri.js | 8 ++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index 72082bd..d2ac16c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.17.7", + "version": "2.17.8", "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 ad030ed..9bd2870 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -775,6 +775,7 @@ function URI_Hysteria2() { ] = /^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec( line, ); + /* eslint-enable no-unused-vars */ if (/^\d+$/.test(port)) { port = parseInt(`${port}`, 10); @@ -818,12 +819,23 @@ function URI_Hysteria2() { if (params.obfs && params.obfs !== 'none') { proxy.obfs = params.obfs; } - - proxy.ports = params.mport; + if (params.mport) { + proxy.ports = params.mport; + } proxy['obfs-password'] = params['obfs-password']; proxy['skip-cert-verify'] = /(TRUE)|1/i.test(params.insecure); proxy.tfo = /(TRUE)|1/i.test(params.fastopen); proxy['tls-fingerprint'] = params.pinSHA256; + let hop_interval = params['hop-interval'] || params['hop_interval']; + + if (/^\d+$/.test(hop_interval)) { + proxy['hop-interval'] = parseInt(`${hop_interval}`, 10); + } + let keepalive = params['keepalive']; + + if (/^\d+$/.test(keepalive)) { + proxy['keepalive'] = parseInt(`${keepalive}`, 10); + } return proxy; }; diff --git a/backend/src/core/proxy-utils/producers/uri.js b/backend/src/core/proxy-utils/producers/uri.js index 5157fef..3836d03 100644 --- a/backend/src/core/proxy-utils/producers/uri.js +++ b/backend/src/core/proxy-utils/producers/uri.js @@ -387,6 +387,14 @@ export default function URI_Producer() { break; case 'hysteria2': let hysteria2params = []; + if (proxy['hop-interval']) { + hysteria2params.push( + `hop-interval=${proxy['hop-interval']}`, + ); + } + if (proxy['keepalive']) { + hysteria2params.push(`keepalive=${proxy['keepalive']}`); + } if (proxy['skip-cert-verify']) { hysteria2params.push(`insecure=1`); }