diff --git a/backend/package.json b/backend/package.json index 51f995568..98549726c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.16.33", + "version": "2.16.34", "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 ec03e4ea0..b14ab6232 100644 --- a/backend/src/core/proxy-utils/index.js +++ b/backend/src/core/proxy-utils/index.js @@ -6,6 +6,7 @@ import { isIPv4, isIPv6, isValidPortNumber, + isValidUUID, isNotBlank, ipAddress, getRandomPort, @@ -76,7 +77,16 @@ function parse(raw) { $.error(`Failed to parse line: ${line}`); } } - return proxies; + return proxies.filter((proxy) => { + if (['vless', 'vmess'].includes(proxy.type)) { + const isProxyUUIDValid = isValidUUID(proxy.uuid); + if (!isProxyUUIDValid) { + $.error(`UUID is invalid: ${proxy.name} ${proxy.uuid}`); + } + return isProxyUUIDValid; + } + return true; + }); } async function processFn( @@ -215,10 +225,22 @@ function produce(proxies, targetPlatform, type, opts = {}) { ); // filter unsupported proxies - proxies = proxies.filter( - (proxy) => - !(proxy.supported && proxy.supported[targetPlatform] === false), - ); + proxies = proxies.filter((proxy) => { + // 检查代理是否支持目标平台 + if (proxy.supported && proxy.supported[targetPlatform] === false) { + return false; + } + + // 对于 vless 和 vmess 代理,需要额外验证 UUID + if (['vless', 'vmess'].includes(proxy.type)) { + const isProxyUUIDValid = isValidUUID(proxy.uuid); + if (!isProxyUUIDValid) + $.error(`UUID is invalid: ${proxy.name} ${proxy.uuid}`); + return isProxyUUIDValid; + } + + return true; + }); proxies = proxies.map((proxy) => { proxy._resolved = proxy.resolved; diff --git a/backend/src/utils/index.js b/backend/src/utils/index.js index 8330beaaa..daf6e769f 100644 --- a/backend/src/utils/index.js +++ b/backend/src/utils/index.js @@ -117,7 +117,17 @@ function numberToString(value) { : BigInt(value).toString(); } +function isValidUUID(uuid) { + return ( + typeof uuid === 'string' && + /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test( + uuid, + ) + ); +} + export { + isValidUUID, ipAddress, isIPv4, isIPv6,