From 72bc9b9456c7345c724499210f70b9121274078f Mon Sep 17 00:00:00 2001 From: xream Date: Wed, 4 Sep 2024 13:39:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=84=E7=90=86=E9=9D=9E=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E7=9A=84=20`ports`=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/index.js | 13 +++++++------ backend/src/core/proxy-utils/producers/surge.js | 7 +++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/package.json b/backend/package.json index 2df8607..6ff2c1b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.376", + "version": "2.14.378", "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 de8e5c3..ddf0d06 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -231,6 +231,7 @@ function produce(proxies, targetPlatform, type, opts = {}) { // 处理 端口跳跃 if (proxy.ports) { + proxy.ports = String(proxy.ports); if (!['ClashMeta'].includes(targetPlatform)) { proxy.ports = proxy.ports.replace(/\//g, ','); } @@ -420,13 +421,13 @@ function lastParse(proxy) { proxy[`${proxy.network}-opts`].path = [transportPath]; } } - if (['hysteria', 'hysteria2'].includes(proxy.type)) { - if (proxy.ports) { - proxy.ports = proxy.ports.replace(/\//g, ','); - } else { - delete proxy.ports; - } + // if (['hysteria', 'hysteria2', 'tuic'].includes(proxy.type)) { + if (proxy.ports) { + proxy.ports = String(proxy.ports).replace(/\//g, ','); + } else { + delete proxy.ports; } + // } if ( ['hysteria2'].includes(proxy.type) && proxy.obfs && diff --git a/backend/src/core/proxy-utils/producers/surge.js b/backend/src/core/proxy-utils/producers/surge.js index 41ac3b7..df62770 100644 --- a/backend/src/core/proxy-utils/producers/surge.js +++ b/backend/src/core/proxy-utils/producers/surge.js @@ -15,6 +15,9 @@ const ipVersions = { export default function Surge_Producer() { const produce = (proxy, type, opts = {}) => { proxy.name = proxy.name.replace(/=|,/g, ''); + if (proxy.ports) { + proxy.ports = String(proxy.ports); + } switch (proxy.type) { case 'ss': return shadowsocks(proxy); @@ -676,7 +679,7 @@ function tuic(proxy) { ); if (isPresent(proxy, 'ports')) { - result.append(`,port-hopping=${proxy.ports.replace(/,/g, ';')}`); + result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`); } result.appendIfPresent( @@ -945,7 +948,7 @@ function hysteria2(proxy) { result.appendIfPresent(`,password=${proxy.password}`, 'password'); if (isPresent(proxy, 'ports')) { - result.append(`,port-hopping=${proxy.ports.replace(/,/g, ';')}`); + result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`); } result.appendIfPresent(