feat: 调整规则参数

This commit is contained in:
xream 2024-02-28 22:33:06 +08:00
parent 56626dabc7
commit b0c1157fe1
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 22 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.228",
"version": "2.14.230",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@ -40,7 +40,7 @@ function AllRuleParser() {
rule.type === 'IP-CIDR' ||
rule.type === 'IP-CIDR6'
) {
rule.options = params.slice(2).join(",");
rule.options = params.slice(2);
}
result.push(rule);
}

View File

@ -30,8 +30,9 @@ function SurgeRuleSet() {
const type = 'SINGLE';
const func = (rule) => {
let output = `${rule.type},${rule.content}`;
if (rule.type === 'IP-CIDR' || rule.type === 'IP-CIDR6') {
output += rule.options ? `,${rule.options}` : '';
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type)) {
output +=
rule.options?.length > 0 ? `,${rule.options.join(',')}` : '';
}
return output;
};
@ -44,6 +45,12 @@ function LoonRules() {
// skip unsupported rules
const UNSUPPORTED = ['DEST-PORT', 'SRC-IP', 'IN-PORT', 'PROTOCOL'];
if (UNSUPPORTED.indexOf(rule.type) !== -1) return null;
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type) && rule.options) {
// Loon only supports the no-resolve option
rule.options = rule.options.filter((option) =>
['no-resolve'].includes(option),
);
}
return SurgeRuleSet().func(rule);
};
return { type, func };
@ -62,8 +69,17 @@ function ClashRuleProvider() {
let output = `${TRANSFORM[rule.type] || rule.type},${
rule.content
}`;
if (rule.type === 'IP-CIDR' || rule.type === 'IP-CIDR6') {
output += rule.options ? `,${rule.options}` : '';
if (['IP-CIDR', 'IP-CIDR6'].includes(rule.type)) {
if (rule.options) {
// Clash only supports the no-resolve option
rule.options = rule.options.filter((option) =>
['no-resolve'].includes(option),
);
}
output +=
rule.options?.length > 0
? `,${rule.options.join(',')}`
: '';
}
return output;
}),