Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web/html
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2024-03-11 23:44:35 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2024-03-12 00:06:25 +0300
commit6af0d55ca9660d0f8d21c7173a6c90c1480cd6e5 (patch)
tree2446a71c4b3926ec877fa03ae4c5054f9bc25692 /web/html
parent0917eb2742003fa9cf83a522e6b9d758c4b3a7de (diff)
improve null handling
Diffstat (limited to 'web/html')
-rw-r--r--web/html/xui/xray.html37
1 files changed, 23 insertions, 14 deletions
diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html
index ba6f0771..56d8f1d6 100644
--- a/web/html/xui/xray.html
+++ b/web/html/xui/xray.html
@@ -1184,22 +1184,21 @@
deleteBalancer(index) {
newTemplateSettings = this.templateSettings;
- //remove from balancers
- const oldTag = this.balancersData[index].tag;
- this.balancersData.splice(index, 1);
+ // Remove from balancers
+ const removedBalancer = this.balancersData.splice(index, 1)[0];
- // remove from settings
- let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag == oldTag);
+ // Remove from settings
+ let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
newTemplateSettings.routing.balancers.splice(realIndex, 1);
- // remove related routing rules
- let rules = [];
- newTemplateSettings.routing.rules.forEach((r) => {
- if (!r.balancerTag || r.balancerTag != oldTag) {
- rules.push(r);
- }
- });
+ // Remove related routing rules
+ let rules = newTemplateSettings.routing.rules.filter((r) => !r.balancerTag || r.balancerTag !== removedBalancer.tag);
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;
},
addReverse(){
@@ -2025,7 +2024,13 @@
},
set: function (newValue) {
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;
}
},
@@ -2061,7 +2066,11 @@
get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
set: function (newValue) {
newTemplateSettings = this.templateSettings;
- newTemplateSettings.fakedns = newValue.length >0 ? newValue : null;
+ if (this.enableDNS) {
+ newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
+ } else {
+ delete newTemplateSettings.fakedns;
+ }
this.templateSettings = newTemplateSettings;
}
}