diff --git a/backend/package.json b/backend/package.json index 259d979..e394784 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.132", + "version": "2.14.133", "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 374a2c0..7130280 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -1,5 +1,5 @@ import download from '@/utils/download'; -import { isIPv4, isIPv6 } from '@/utils'; +import { isIPv4, isIPv6, isValidPortNumber } from '@/utils'; import PROXY_PROCESSORS, { ApplyProcessor } from './processors'; import PROXY_PREPROCESSORS from './preprocessors'; import PROXY_PRODUCERS from './producers'; @@ -214,6 +214,9 @@ function safeMatch(parser, line) { } function lastParse(proxy) { + if (isValidPortNumber(proxy.port)) { + proxy.port = parseInt(proxy.port, 10); + } if (proxy.server) { proxy.server = proxy.server .trim() diff --git a/backend/src/utils/index.js b/backend/src/utils/index.js index c897216..0502b92 100644 --- a/backend/src/utils/index.js +++ b/backend/src/utils/index.js @@ -13,6 +13,12 @@ function isIPv6(ip) { return IPV6_REGEX.test(ip); } +function isValidPortNumber(port) { + return /^((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$/.test( + port, + ); +} + function isNotBlank(str) { return typeof str === 'string' && str.trim().length > 0; } @@ -29,4 +35,12 @@ function getIfPresent(obj, defaultValue) { return isPresent(obj) ? obj : defaultValue; } -export { isIPv4, isIPv6, isNotBlank, getIfNotBlank, isPresent, getIfPresent }; +export { + isIPv4, + isIPv6, + isValidPortNumber, + isNotBlank, + getIfNotBlank, + isPresent, + getIfPresent, +};