Skip to content

Commit b0c1157

Browse files
committed
feat: 调整规则参数
1 parent 56626da commit b0c1157

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.14.228",
3+
"version": "2.14.230",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/rule-utils/parsers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function AllRuleParser() {
4040
rule.type === 'IP-CIDR' ||
4141
rule.type === 'IP-CIDR6'
4242
) {
43-
rule.options = params.slice(2).join(",");
43+
rule.options = params.slice(2);
4444
}
4545
result.push(rule);
4646
}

backend/src/core/rule-utils/producers.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ function SurgeRuleSet() {
3030
const type = 'SINGLE';
3131
const func = (rule) => {
3232
let output = `${rule.type},${rule.content}`;
33-
if (rule.type === 'IP-CIDR' || rule.type === 'IP-CIDR6') {
34-
output += rule.options ? `,${rule.options}` : '';
33+
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type)) {
34+
output +=
35+
rule.options?.length > 0 ? `,${rule.options.join(',')}` : '';
3536
}
3637
return output;
3738
};
@@ -44,6 +45,12 @@ function LoonRules() {
4445
// skip unsupported rules
4546
const UNSUPPORTED = ['DEST-PORT', 'SRC-IP', 'IN-PORT', 'PROTOCOL'];
4647
if (UNSUPPORTED.indexOf(rule.type) !== -1) return null;
48+
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type) && rule.options) {
49+
// Loon only supports the no-resolve option
50+
rule.options = rule.options.filter((option) =>
51+
['no-resolve'].includes(option),
52+
);
53+
}
4754
return SurgeRuleSet().func(rule);
4855
};
4956
return { type, func };
@@ -62,8 +69,17 @@ function ClashRuleProvider() {
6269
let output = `${TRANSFORM[rule.type] || rule.type},${
6370
rule.content
6471
}`;
65-
if (rule.type === 'IP-CIDR' || rule.type === 'IP-CIDR6') {
66-
output += rule.options ? `,${rule.options}` : '';
72+
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type)) {
73+
if (rule.options) {
74+
// Clash only supports the no-resolve option
75+
rule.options = rule.options.filter((option) =>
76+
['no-resolve'].includes(option),
77+
);
78+
}
79+
output +=
80+
rule.options?.length > 0
81+
? `,${rule.options.join(',')}`
82+
: '';
6783
}
6884
return output;
6985
}),

0 commit comments

Comments
 (0)