Skip to content

Commit

Permalink
feat: 节点上的额外参数调整为下划线开头, 原参数目前仍保留, 若有脚本需要使用这些参数请尽快修改(_subName, _collec…
Browse files Browse the repository at this point in the history
…tionName, _resolved, _no-resolve)
  • Loading branch information
xream committed May 29, 2024
1 parent 47849dc commit 047c21f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
11 changes: 8 additions & 3 deletions backend/src/core/proxy-utils/processors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
];
Expand All @@ -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(
Expand Down Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/producers/clash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/producers/clashmeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/producers/shadowrocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/producers/stash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/producers/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 开始递增(暂不支持配置)
Expand Down

0 comments on commit 047c21f

Please sign in to comment.