From 23e8fbd1b7e988ad9ca213ef830d9e0a1b3b9f2e Mon Sep 17 00:00:00 2001 From: xream Date: Thu, 6 Feb 2025 14:59:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Proxy=20URI=20Scheme=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9C=81=E7=95=A5=E7=AB=AF=E5=8F=A3=E5=8F=B7(http=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA=2080,=20tls=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA=20443)?= 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 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index bc7cfb5..d87815e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.16.27", + "version": "2.16.28", "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 e29be4d..3daab08 100644 --- a/backend/src/core/proxy-utils/parsers/index.js +++ b/backend/src/core/proxy-utils/parsers/index.js @@ -11,6 +11,7 @@ import getSurgeParser from './peggy/surge'; import getLoonParser from './peggy/loon'; import getQXParser from './peggy/qx'; import getTrojanURIParser from './peggy/trojan-uri'; +import $ from '@/core/app'; import { Base64 } from 'js-base64'; @@ -40,8 +41,21 @@ function URI_PROXY() { // eslint-disable-next-line no-unused-vars let [__, type, tls, username, password, server, port, query, name] = line.match( - /^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?):(\d+?)(\?.*?)?(?:#(.*?))?$/, + /^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/, ); + if (port) { + port = parseInt(port, 10); + } else { + if (tls) { + port = 443; + } else if (type === 'http') { + port = 80; + } else { + $.error(`port is not present in line: ${line}`); + throw new Error(`port is not present in line: ${line}`); + } + $.info(`port is not present in line: ${line}, set to ${port}`); + } const proxy = { name: