From 047c21fe70a7407fd26df26244ce86bdf3206e71 Mon Sep 17 00:00:00 2001 From: xream Date: Thu, 30 May 2024 04:48:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8A=82=E7=82=B9=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E9=A2=9D=E5=A4=96=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E4=B8=8B=E5=88=92=E7=BA=BF=E5=BC=80=E5=A4=B4,=20=E5=8E=9F?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=9B=AE=E5=89=8D=E4=BB=8D=E4=BF=9D=E7=95=99?= =?UTF-8?q?,=20=E8=8B=A5=E6=9C=89=E8=84=9A=E6=9C=AC=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=BF=99=E4=BA=9B=E5=8F=82=E6=95=B0=E8=AF=B7?= =?UTF-8?q?=E5=B0=BD=E5=BF=AB=E4=BF=AE=E6=94=B9(=5FsubName,=20=5Fcollectio?= =?UTF-8?q?nName,=20=5Fresolved,=20=5Fno-resolve)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/core/proxy-utils/processors/index.js | 11 ++++++++--- backend/src/core/proxy-utils/producers/clash.js | 1 + backend/src/core/proxy-utils/producers/clashmeta.js | 1 + .../src/core/proxy-utils/producers/shadowrocket.js | 1 + backend/src/core/proxy-utils/producers/stash.js | 1 + backend/src/core/proxy-utils/producers/uri.js | 1 + scripts/demo.js | 2 +- 8 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index 88225d0e5..fe46f3a5f 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.321", + "version": "2.14.322", "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 2e8d84f24..7f1ecbbb0 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -512,12 +512,17 @@ function ResolveDomainOperator({ provider, type: _type, filter, cache }) { return { name: 'Resolve Domain Operator', func: async (proxies) => { + proxies.forEach((p, i) => { + if (!p['_no-resolve'] && p['no-resolve']) { + proxies[i]['_no-resolve'] = p['no-resolve']; + } + }); const results = {}; const limit = 15; // more than 20 concurrency may result in surge TCP connection shortage. const totalDomain = [ ...new Set( proxies - .filter((p) => !isIP(p.server) && !p['no-resolve']) + .filter((p) => !isIP(p.server) && !p['_no-resolve']) .map((c) => c.server), ), ]; @@ -543,7 +548,7 @@ function ResolveDomainOperator({ provider, type: _type, filter, cache }) { await Promise.all(currentBatch); } proxies.forEach((p) => { - if (!p['no-resolve']) { + if (!p['_no-resolve']) { if (results[p.server]) { if (_type === 'IP4P') { const { server, port } = parseIP4P( @@ -578,7 +583,7 @@ function ResolveDomainOperator({ provider, type: _type, filter, cache }) { return proxies.filter((p) => { if (filter === 'removeFailed') { - return isIP(p.server) || p['no-resolve'] || p.resolved; + return isIP(p.server) || p['_no-resolve'] || p.resolved; } else if (filter === 'IPOnly') { return isIP(p.server); } else if (filter === 'IPv4Only') { diff --git a/backend/src/core/proxy-utils/producers/clash.js b/backend/src/core/proxy-utils/producers/clash.js index 800532c70..eeb95ff9b 100644 --- a/backend/src/core/proxy-utils/producers/clash.js +++ b/backend/src/core/proxy-utils/producers/clash.js @@ -158,6 +158,7 @@ export default function Clash_Producer() { delete proxy.collectionName; delete proxy.id; delete proxy.resolved; + delete proxy['no-resolve']; for (const key in proxy) { if (proxy[key] == null || /^_/i.test(key)) { delete proxy[key]; diff --git a/backend/src/core/proxy-utils/producers/clashmeta.js b/backend/src/core/proxy-utils/producers/clashmeta.js index 54680cb6d..bb8376c96 100644 --- a/backend/src/core/proxy-utils/producers/clashmeta.js +++ b/backend/src/core/proxy-utils/producers/clashmeta.js @@ -173,6 +173,7 @@ export default function ClashMeta_Producer() { delete proxy.collectionName; delete proxy.id; delete proxy.resolved; + delete proxy['no-resolve']; for (const key in proxy) { if (proxy[key] == null || /^_/i.test(key)) { delete proxy[key]; diff --git a/backend/src/core/proxy-utils/producers/shadowrocket.js b/backend/src/core/proxy-utils/producers/shadowrocket.js index 6f4709398..041e06a8d 100644 --- a/backend/src/core/proxy-utils/producers/shadowrocket.js +++ b/backend/src/core/proxy-utils/producers/shadowrocket.js @@ -176,6 +176,7 @@ export default function ShadowRocket_Producer() { delete proxy.collectionName; delete proxy.id; delete proxy.resolved; + delete proxy['no-resolve']; for (const key in proxy) { if (proxy[key] == null || /^_/i.test(key)) { delete proxy[key]; diff --git a/backend/src/core/proxy-utils/producers/stash.js b/backend/src/core/proxy-utils/producers/stash.js index 5c6343047..b6585ac0e 100644 --- a/backend/src/core/proxy-utils/producers/stash.js +++ b/backend/src/core/proxy-utils/producers/stash.js @@ -265,6 +265,7 @@ export default function Stash_Producer() { delete proxy.collectionName; delete proxy.id; delete proxy.resolved; + delete proxy['no-resolve']; for (const key in proxy) { if (proxy[key] == null || /^_/i.test(key)) { delete proxy[key]; diff --git a/backend/src/core/proxy-utils/producers/uri.js b/backend/src/core/proxy-utils/producers/uri.js index c2150ec56..a0410b81d 100644 --- a/backend/src/core/proxy-utils/producers/uri.js +++ b/backend/src/core/proxy-utils/producers/uri.js @@ -10,6 +10,7 @@ export default function URI_Producer() { delete proxy.collectionName; delete proxy.id; delete proxy.resolved; + delete proxy['no-resolve']; for (const key in proxy) { if (proxy[key] == null || /^_/i.test(key)) { delete proxy[key]; diff --git a/scripts/demo.js b/scripts/demo.js index 92b879b4d..0d790f423 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -7,7 +7,7 @@ function operator(proxies = [], targetPlatform, context) { // proxies 为传入的内部节点数组 // 结构大致参考了 Clash.Meta(mihomo) 有私货 // 可在预览界面点击节点查看 JSON 结构 或查看 `target=JSON` 的通用订阅 - // 1. `no-resolve` 为不解析域名 + // 1. `_no-resolve` 为不解析域名 // 2. 域名解析后 会多一个 `_resolved` 字段 // 3. 域名解析后会有`_IPv4`, `_IPv6`, `_IP`(若有多个步骤, 只取第一次成功的 v4 或 v6 数据), `_domain` 字段 // 4. 节点字段 `exec` 为 `ssr-local` 路径, 默认 `/usr/local/bin/ssr-local`; 端口从 10000 开始递增(暂不支持配置)