feat: 优化去除无效节点逻辑 感谢群友 Cooip JM

This commit is contained in:
xream 2024-12-05 12:45:07 +08:00
parent 4ea84118c4
commit dbf9e7c360
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 35 additions and 14 deletions

View File

@ -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": {

View File

@ -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,
);
}
});
},
};
}