mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-20 05:52:24 +00:00
fix subJson direct rules (#2580)
This commit is contained in:
parent
c385662783
commit
fb2b58110d
1 changed files with 44 additions and 29 deletions
|
@ -464,8 +464,7 @@
|
||||||
outboundTag: "direct",
|
outboundTag: "direct",
|
||||||
domain: [
|
domain: [
|
||||||
"geosite:category-ir"
|
"geosite:category-ir"
|
||||||
],
|
]
|
||||||
"enabled": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "field",
|
type: "field",
|
||||||
|
@ -473,8 +472,7 @@
|
||||||
ip: [
|
ip: [
|
||||||
"geoip:private",
|
"geoip:private",
|
||||||
"geoip:ir"
|
"geoip:ir"
|
||||||
],
|
]
|
||||||
enabled: true
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
geoIPOptions: [
|
geoIPOptions: [
|
||||||
|
@ -751,16 +749,25 @@
|
||||||
get: function () {
|
get: function () {
|
||||||
if (!this.enableDirect) return [];
|
if (!this.enableDirect) return [];
|
||||||
const rules = JSON.parse(this.allSetting.subJsonRules);
|
const rules = JSON.parse(this.allSetting.subJsonRules);
|
||||||
return Array.isArray(rules) ? rules[1].ip.map(d => d.replace("geoip:", "")) : [];
|
if (!Array.isArray(rules)) return [];
|
||||||
|
const ipRule = rules.find(r => r.ip);
|
||||||
|
return ipRule?.ip.map(d => d.replace("geoip:", "")) ?? [];
|
||||||
},
|
},
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
const rules = JSON.parse(this.allSetting.subJsonRules);
|
let rules = JSON.parse(this.allSetting.subJsonRules);
|
||||||
if (!Array.isArray(rules)) return;
|
if (!Array.isArray(rules)) return;
|
||||||
|
|
||||||
rules[1].ip = [];
|
if (v.length == 0) {
|
||||||
v.forEach(d => {
|
rules = rules.filter(r => !r.ip);
|
||||||
rules[1].ip.push("geoip:" + d);
|
} else {
|
||||||
});
|
let ruleIndex = rules.findIndex(r => r.ip);
|
||||||
|
if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[1]) - 1;
|
||||||
|
|
||||||
|
rules[ruleIndex].ip = [];
|
||||||
|
v.forEach(d => {
|
||||||
|
rules[ruleIndex].ip.push("geoip:" + d);
|
||||||
|
});
|
||||||
|
}
|
||||||
this.allSetting.subJsonRules = JSON.stringify(rules);
|
this.allSetting.subJsonRules = JSON.stringify(rules);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -768,29 +775,37 @@
|
||||||
get: function () {
|
get: function () {
|
||||||
if (!this.enableDirect) return [];
|
if (!this.enableDirect) return [];
|
||||||
const rules = JSON.parse(this.allSetting.subJsonRules);
|
const rules = JSON.parse(this.allSetting.subJsonRules);
|
||||||
return Array.isArray(rules) ?
|
if (!Array.isArray(rules)) return [];
|
||||||
rules[0].domain.map(d => {
|
const domainRule = rules.find(r => r.domain);
|
||||||
if (d.startsWith("geosite:category-")) {
|
return domainRule?.domain.map(d => {
|
||||||
return d.replace("geosite:category-", "");
|
if (d.startsWith("geosite:category-")) {
|
||||||
}
|
return d.replace("geosite:category-", "");
|
||||||
return d.replace("geosite:", "");
|
}
|
||||||
})
|
return d.replace("geosite:", "");
|
||||||
: [];
|
})
|
||||||
|
?? [];
|
||||||
},
|
},
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
const rules = JSON.parse(this.allSetting.subJsonRules);
|
let rules = JSON.parse(this.allSetting.subJsonRules);
|
||||||
if (!Array.isArray(rules)) return;
|
if (!Array.isArray(rules)) return;
|
||||||
|
|
||||||
rules[0].domain = [];
|
if (v.length == 0) {
|
||||||
v.forEach(d => {
|
rules = rules.filter(r => !r.domain);
|
||||||
let category = '';
|
} else {
|
||||||
if (["cn", "apple", "meta", "google"].includes(d)) {
|
let ruleIndex = rules.findIndex(r => r.domain);
|
||||||
category = "";
|
if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
|
||||||
} else if (["ru", "ir"].includes(d)) {
|
|
||||||
category = "category-";
|
rules[ruleIndex].domain = [];
|
||||||
}
|
v.forEach(d => {
|
||||||
rules[0].domain.push("geosite:" + category + d);
|
let category = '';
|
||||||
});
|
if (["cn", "apple", "meta", "google"].includes(d)) {
|
||||||
|
category = "";
|
||||||
|
} else if (["ru", "ir"].includes(d)) {
|
||||||
|
category = "category-";
|
||||||
|
}
|
||||||
|
rules[ruleIndex].domain.push("geosite:" + category + d);
|
||||||
|
});
|
||||||
|
}
|
||||||
this.allSetting.subJsonRules = JSON.stringify(rules);
|
this.allSetting.subJsonRules = JSON.stringify(rules);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue