From 662268c5467622fb97001614372e80fc2bb368f4 Mon Sep 17 00:00:00 2001 From: xream Date: Fri, 8 Dec 2023 17:53:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=20IPv6=20=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=20URI?= 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 | 6 ++++++ backend/src/core/proxy-utils/producers/uri.js | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index cf86473..b425b74 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.114", + "version": "2.14.115", "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 af549e5..af93c12 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -214,6 +214,12 @@ function safeMatch(parser, line) { } function lastParse(proxy) { + if (proxy.server) { + proxy.server = proxy.server + .trim() + .replace(/^\[/, '') + .replace(/\]$/, ''); + } if (proxy.type === 'trojan') { if (proxy.network === 'tcp') { delete proxy.network; diff --git a/backend/src/core/proxy-utils/producers/uri.js b/backend/src/core/proxy-utils/producers/uri.js index b996362..a806302 100644 --- a/backend/src/core/proxy-utils/producers/uri.js +++ b/backend/src/core/proxy-utils/producers/uri.js @@ -1,10 +1,14 @@ /* eslint-disable no-case-declarations */ import { Base64 } from 'js-base64'; +import { isIPv6 } from '@/utils'; export default function URI_Producer() { const type = 'SINGLE'; const produce = (proxy) => { let result = ''; + if (proxy.server && isIPv6(proxy.server)) { + proxy.server = `[${proxy.server}]`; + } switch (proxy.type) { case 'ss': const userinfo = `${proxy.cipher}:${proxy.password}`; @@ -246,7 +250,9 @@ export default function URI_Producer() { } if (proxy['tls-fingerprint']) { hysteria2params.push( - `pinSHA256=${encodeURIComponent(proxy['tls-fingerprint'])}`, + `pinSHA256=${encodeURIComponent( + proxy['tls-fingerprint'], + )}`, ); } if (proxy.tfo) {