mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-22 16:55:49 +00:00
improve null handling
Co-Authored-By: MHSanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
@@ -1133,21 +1133,20 @@
|
|||||||
newTemplateSettings = this.templateSettings;
|
newTemplateSettings = this.templateSettings;
|
||||||
|
|
||||||
//remove from balancers
|
//remove from balancers
|
||||||
const oldTag = this.balancersData[index].tag;
|
const removedBalancer = this.balancersData.splice(index, 1)[0];
|
||||||
this.balancersData.splice(index, 1);
|
|
||||||
|
|
||||||
// remove from settings
|
// Remove from settings
|
||||||
let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag == oldTag);
|
let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
|
||||||
newTemplateSettings.routing.balancers.splice(realIndex, 1);
|
newTemplateSettings.routing.balancers.splice(realIndex, 1);
|
||||||
|
|
||||||
// remove related routing rules
|
// Remove related routing rules
|
||||||
let rules = [];
|
let rules = newTemplateSettings.routing.rules.filter((r) => !r.balancerTag || r.balancerTag !== removedBalancer.tag);
|
||||||
newTemplateSettings.routing.rules.forEach((r) => {
|
|
||||||
if (!r.balancerTag || r.balancerTag != oldTag) {
|
|
||||||
rules.push(r);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
newTemplateSettings.routing.rules = rules;
|
newTemplateSettings.routing.rules = rules;
|
||||||
|
|
||||||
|
// Update balancers property to an empty array if there are no more balancers
|
||||||
|
if (newTemplateSettings.routing.balancers.length === 0) {
|
||||||
|
delete newTemplateSettings.routing.balancers;
|
||||||
|
}
|
||||||
this.templateSettings = newTemplateSettings;
|
this.templateSettings = newTemplateSettings;
|
||||||
},
|
},
|
||||||
addDNSServer(){
|
addDNSServer(){
|
||||||
@@ -1779,7 +1778,13 @@
|
|||||||
},
|
},
|
||||||
set: function (newValue) {
|
set: function (newValue) {
|
||||||
newTemplateSettings = this.templateSettings;
|
newTemplateSettings = this.templateSettings;
|
||||||
newTemplateSettings.dns = newValue ? { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" } : null;
|
if (newValue) {
|
||||||
|
newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" };
|
||||||
|
newTemplateSettings.fakedns = null;
|
||||||
|
} else {
|
||||||
|
delete newTemplateSettings.dns;
|
||||||
|
delete newTemplateSettings.fakedns;
|
||||||
|
}
|
||||||
this.templateSettings = newTemplateSettings;
|
this.templateSettings = newTemplateSettings;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user