From dbf9e7c3600130b0df01ee0d9131e961077844cd Mon Sep 17 00:00:00 2001 From: xream Date: Thu, 5 Dec 2024 12:45:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E6=95=88=E8=8A=82=E7=82=B9=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E6=84=9F=E8=B0=A2=E7=BE=A4=E5=8F=8B=20Cooip=20JM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../src/core/proxy-utils/processors/index.js | 47 ++++++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/backend/package.json b/backend/package.json index cc1a245..04c14a3 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.435", + "version": "2.14.436", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/processors/index.js b/backend/src/core/proxy-utils/processors/index.js index 986c57f..5c59223 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -699,24 +699,45 @@ function isIP(ip) { ResolveDomainOperator.resolver = DOMAIN_RESOLVERS; +function isAscii(str) { + // eslint-disable-next-line no-control-regex + var pattern = /^[\x00-\x7F]+$/; // ASCII 范围的 Unicode 编码 + return pattern.test(str); +} + /**************************** Filters ***************************************/ // filter useless proxies function UselessFilter() { - const KEYWORDS = [ - '网址', - '流量', - '时间', - '应急', - '过期', - 'Bandwidth', - 'expire', - ]; return { name: 'Useless Filter', - func: RegexFilter({ - regex: KEYWORDS, - keep: false, - }).func, + func: (proxies) => { + return proxies.map((proxy) => { + if (proxy.cipher && !isAscii(proxy.cipher)) { + return false; + } else if (proxy.password && !isAscii(proxy.password)) { + return false; + } else { + if (proxy.network) { + let transportHosts = + proxy[`${proxy.network}-opts`]?.headers?.Host || + proxy[`${proxy.network}-opts`]?.headers?.host; + transportHosts = Array.isArray(transportHosts) + ? transportHosts + : [transportHosts]; + if ( + transportHosts.some( + (host) => host && !isAscii(host), + ) + ) { + return false; + } + } + return !/网址|流量|时间|应急|过期|Bandwidth|expire/.test( + proxy.name, + ); + } + }); + }, }; }