mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
fix settings and xray page state leaks
This commit is contained in:
parent
3e1b6ed76f
commit
6564cf8202
2 changed files with 84 additions and 87 deletions
|
|
@ -206,11 +206,11 @@
|
|||
{ label: 'Google', value: 'geosite:google' },
|
||||
],
|
||||
get remarkModel() {
|
||||
rm = this.allSetting.remarkModel;
|
||||
const rm = this.allSetting.remarkModel;
|
||||
return rm.length > 1 ? rm.substring(1).split('') : [];
|
||||
},
|
||||
set remarkModel(value) {
|
||||
rs = this.allSetting.remarkModel[0];
|
||||
const rs = this.allSetting.remarkModel[0];
|
||||
this.allSetting.remarkModel = rs + value.join('');
|
||||
this.changeRemarkSample();
|
||||
},
|
||||
|
|
@ -228,7 +228,7 @@
|
|||
this.allSetting.datepicker = value;
|
||||
},
|
||||
changeRemarkSample() {
|
||||
sample = []
|
||||
const sample = [];
|
||||
this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
|
||||
this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
|
||||
}
|
||||
|
|
@ -355,13 +355,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
let finalHost = this.entryHost;
|
||||
const finalHost = webDomain && this._isIp(webDomain) ? webDomain : this.entryHost;
|
||||
let finalPort = this.entryPort || "";
|
||||
|
||||
if (webDomain && this._isIp(webDomain)) {
|
||||
finalHost = webDomain;
|
||||
}
|
||||
|
||||
if (webPort && Number(webPort) !== Number(this.entryPort)) {
|
||||
finalPort = String(webPort);
|
||||
}
|
||||
|
|
@ -457,7 +453,7 @@
|
|||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
|
||||
set: function (v) {
|
||||
if (v != "") {
|
||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
const newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
newFragment.settings.fragment.packets = v;
|
||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||
}
|
||||
|
|
@ -467,7 +463,7 @@
|
|||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
|
||||
set: function (v) {
|
||||
if (v != "") {
|
||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
const newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
newFragment.settings.fragment.length = v;
|
||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||
}
|
||||
|
|
@ -477,7 +473,7 @@
|
|||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
|
||||
set: function (v) {
|
||||
if (v != "") {
|
||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
const newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
newFragment.settings.fragment.interval = v;
|
||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||
}
|
||||
|
|
@ -487,7 +483,7 @@
|
|||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.maxSplit : ""; },
|
||||
set: function (v) {
|
||||
if (v != "") {
|
||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
const newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||
newFragment.settings.fragment.maxSplit = v;
|
||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||
}
|
||||
|
|
@ -526,7 +522,7 @@
|
|||
muxConcurrency: {
|
||||
get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
|
||||
set: function (v) {
|
||||
newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
const newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
newMux.concurrency = v;
|
||||
this.allSetting.subJsonMux = JSON.stringify(newMux);
|
||||
}
|
||||
|
|
@ -534,7 +530,7 @@
|
|||
muxXudpConcurrency: {
|
||||
get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
|
||||
set: function (v) {
|
||||
newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
const newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
newMux.xudpConcurrency = v;
|
||||
this.allSetting.subJsonMux = JSON.stringify(newMux);
|
||||
}
|
||||
|
|
@ -542,7 +538,7 @@
|
|||
muxXudpProxyUDP443: {
|
||||
get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
|
||||
set: function (v) {
|
||||
newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
const newMux = JSON.parse(this.allSetting.subJsonMux);
|
||||
newMux.xudpProxyUDP443 = v;
|
||||
this.allSetting.subJsonMux = JSON.stringify(newMux);
|
||||
}
|
||||
|
|
@ -607,14 +603,14 @@
|
|||
var alerts = []
|
||||
if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
|
||||
if (this.allSetting.webPort === 2053) alerts.push('{{ i18n "secAlertPanelPort" }}');
|
||||
panelPath = window.location.pathname.split('/').length < 4
|
||||
const panelPath = window.location.pathname.split('/').length < 4
|
||||
if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
|
||||
if (this.allSetting.subEnable) {
|
||||
subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
|
||||
const subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
|
||||
if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
|
||||
}
|
||||
if (this.allSetting.subJsonEnable) {
|
||||
subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
|
||||
const subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
|
||||
if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
|
||||
}
|
||||
return alerts
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@
|
|||
const { data, property, outboundTag } = routeSettings;
|
||||
const oldTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = oldTemplateSettings;
|
||||
currentProperty = this.templateRuleGetter({ outboundTag, property })
|
||||
const currentProperty = this.templateRuleGetter({ outboundTag, property })
|
||||
if (currentProperty.length == 0) {
|
||||
const propertyRule = {
|
||||
type: "field",
|
||||
|
|
@ -494,7 +494,7 @@
|
|||
}
|
||||
else {
|
||||
const newRules = [];
|
||||
insertedOnce = false;
|
||||
let insertedOnce = false;
|
||||
newTemplateSettings.routing.rules.forEach(
|
||||
(routingRule) => {
|
||||
if (
|
||||
|
|
@ -521,11 +521,11 @@
|
|||
if (this.cm != null) {
|
||||
this.cm.toTextArea();
|
||||
}
|
||||
textAreaObj = document.getElementById('xraySetting');
|
||||
const textAreaObj = document.getElementById('xraySetting');
|
||||
textAreaObj.value = this[this.advSettings];
|
||||
this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
|
||||
this.cm.on('change', editor => {
|
||||
value = editor.getValue();
|
||||
const value = editor.getValue();
|
||||
if (this.isJsonString(value)) {
|
||||
this[this.advSettings] = value;
|
||||
}
|
||||
|
|
@ -539,11 +539,11 @@
|
|||
this.cm = null;
|
||||
return
|
||||
}
|
||||
textAreaObj = document.getElementById('obsSetting');
|
||||
const textAreaObj = document.getElementById('obsSetting');
|
||||
textAreaObj.value = this[this.obsSettings];
|
||||
this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
|
||||
this.cm.on('change', editor => {
|
||||
value = editor.getValue();
|
||||
const value = editor.getValue();
|
||||
if (this.isJsonString(value)) {
|
||||
this[this.obsSettings] = value;
|
||||
}
|
||||
|
|
@ -566,7 +566,7 @@
|
|||
return `${SizeFormatter.sizeFormat(0)} / ${SizeFormatter.sizeFormat(0)}`
|
||||
},
|
||||
findOutboundAddress(o) {
|
||||
serverObj = null;
|
||||
let serverObj = null;
|
||||
switch (o.protocol) {
|
||||
case Protocols.VMess:
|
||||
serverObj = o.settings.vnext;
|
||||
|
|
@ -619,12 +619,12 @@
|
|||
});
|
||||
},
|
||||
deleteOutbound(index) {
|
||||
outbounds = this.templateSettings.outbounds;
|
||||
const outbounds = this.templateSettings.outbounds;
|
||||
outbounds.splice(index, 1);
|
||||
this.outboundSettings = JSON.stringify(outbounds);
|
||||
},
|
||||
setFirstOutbound(index) {
|
||||
outbounds = this.templateSettings.outbounds;
|
||||
const outbounds = this.templateSettings.outbounds;
|
||||
outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
|
||||
this.outboundSettings = JSON.stringify(outbounds);
|
||||
},
|
||||
|
|
@ -700,7 +700,7 @@
|
|||
confirm: (reverse, rules) => {
|
||||
reverseModal.loading();
|
||||
if (reverse.tag.length > 0) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
|
||||
if (newTemplateSettings.reverse[reverse.type + 's'] == undefined) newTemplateSettings.reverse[reverse.type + 's'] = [];
|
||||
newTemplateSettings.reverse[reverse.type + 's'].push({ tag: reverse.tag, domain: reverse.domain });
|
||||
|
|
@ -716,6 +716,7 @@
|
|||
});
|
||||
},
|
||||
editReverse(index) {
|
||||
let oldRules;
|
||||
if (this.reverseData[index].type == "bridge") {
|
||||
oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
|
||||
} else {
|
||||
|
|
@ -728,11 +729,11 @@
|
|||
confirm: (reverse, rules) => {
|
||||
reverseModal.loading();
|
||||
if (reverse.tag.length > 0) {
|
||||
oldData = this.reverseData[index];
|
||||
newTemplateSettings = this.templateSettings;
|
||||
oldReverseIndex = newTemplateSettings.reverse[oldData.type + 's'].findIndex(rs => rs.tag == oldData.tag);
|
||||
oldRuleIndex0 = oldRules.length > 0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
|
||||
oldRuleIndex1 = oldRules.length == 2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
|
||||
const oldData = this.reverseData[index];
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
const oldReverseIndex = newTemplateSettings.reverse[oldData.type + 's'].findIndex(rs => rs.tag == oldData.tag);
|
||||
const oldRuleIndex0 = oldRules.length > 0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
|
||||
const oldRuleIndex1 = oldRules.length == 2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
|
||||
if (oldData.type == reverse.type) {
|
||||
newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
|
||||
} else {
|
||||
|
|
@ -746,7 +747,7 @@
|
|||
this.templateSettings = newTemplateSettings;
|
||||
|
||||
// Adjust Rules
|
||||
newRules = this.templateSettings.routing.rules;
|
||||
const newRules = this.templateSettings.routing.rules;
|
||||
oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
|
||||
oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
|
||||
this.routingRuleSettings = JSON.stringify(newRules);
|
||||
|
|
@ -757,10 +758,10 @@
|
|||
});
|
||||
},
|
||||
deleteReverse(index) {
|
||||
oldData = this.reverseData[index];
|
||||
newTemplateSettings = this.templateSettings;
|
||||
reverseTypeObj = newTemplateSettings.reverse[oldData.type + 's'];
|
||||
realIndex = reverseTypeObj.findIndex(r => r.tag == oldData.tag && r.domain == oldData.domain);
|
||||
const oldData = this.reverseData[index];
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
const reverseTypeObj = newTemplateSettings.reverse[oldData.type + 's'];
|
||||
const realIndex = reverseTypeObj.findIndex(r => r.tag == oldData.tag && r.domain == oldData.domain);
|
||||
newTemplateSettings.reverse[oldData.type + 's'].splice(realIndex, 1);
|
||||
|
||||
// delete empty objects
|
||||
|
|
@ -768,7 +769,7 @@
|
|||
if (Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
|
||||
|
||||
// delete related routing rules
|
||||
newRules = newTemplateSettings.routing.rules;
|
||||
let newRules = newTemplateSettings.routing.rules;
|
||||
if (oldData.type == "bridge") {
|
||||
newRules = newTemplateSettings.routing.rules.filter(r => !(r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
|
||||
} else if (oldData.type == "portal") {
|
||||
|
|
@ -783,7 +784,7 @@
|
|||
this.refreshing = true;
|
||||
await this.getOutboundsTraffic();
|
||||
|
||||
data = []
|
||||
const data = []
|
||||
if (this.templateSettings != null) {
|
||||
this.templateSettings.outbounds.forEach((o, index) => {
|
||||
data.push({ 'key': index, ...o });
|
||||
|
|
@ -817,11 +818,11 @@
|
|||
},
|
||||
confirm: (balancer) => {
|
||||
balancerModal.loading();
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newTemplateSettings.routing.balancers == undefined) {
|
||||
newTemplateSettings.routing.balancers = [];
|
||||
}
|
||||
let tmpBalancer = {
|
||||
const tmpBalancer = {
|
||||
'tag': balancer.tag,
|
||||
'selector': balancer.selector,
|
||||
'fallbackTag': balancer.fallbackTag
|
||||
|
|
@ -849,9 +850,9 @@
|
|||
balancer: this.balancersData[index],
|
||||
confirm: (balancer) => {
|
||||
balancerModal.loading();
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
|
||||
let tmpBalancer = {
|
||||
const tmpBalancer = {
|
||||
'tag': balancer.tag,
|
||||
'selector': balancer.selector,
|
||||
'fallbackTag': balancer.fallbackTag
|
||||
|
|
@ -889,7 +890,7 @@
|
|||
});
|
||||
},
|
||||
updateObservatorySelectors() {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
const leastPings = this.balancersData.filter((b) => b.strategy == 'leastPing');
|
||||
const leastLoads = this.balancersData.filter((b) =>
|
||||
b.strategy === 'leastLoad' ||
|
||||
|
|
@ -926,7 +927,7 @@
|
|||
this.changeObsCode();
|
||||
},
|
||||
deleteBalancer(index) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
|
||||
// Remove from balancers
|
||||
const removedBalancer = this.balancersData.splice(index, 1)[0];
|
||||
|
|
@ -958,7 +959,7 @@
|
|||
dnsModal.show({
|
||||
title: '{{ i18n "pages.xray.dns.add" }}',
|
||||
confirm: (dnsServer) => {
|
||||
dnsServers = this.dnsServers;
|
||||
const dnsServers = this.dnsServers;
|
||||
dnsServers.push(dnsServer);
|
||||
this.dnsServers = dnsServers;
|
||||
dnsModal.close();
|
||||
|
|
@ -971,7 +972,7 @@
|
|||
title: '{{ i18n "pages.xray.dns.edit" }} #' + (index + 1),
|
||||
dnsServer: this.dnsServers[index],
|
||||
confirm: (dnsServer) => {
|
||||
dnsServers = this.dnsServers;
|
||||
const dnsServers = this.dnsServers;
|
||||
dnsServers[index] = dnsServer;
|
||||
this.dnsServers = dnsServers;
|
||||
dnsModal.close();
|
||||
|
|
@ -980,7 +981,7 @@
|
|||
});
|
||||
},
|
||||
deleteDNSServer(index) {
|
||||
newDnsServers = this.dnsServers;
|
||||
const newDnsServers = this.dnsServers;
|
||||
newDnsServers.splice(index, 1);
|
||||
this.dnsServers = newDnsServers;
|
||||
},
|
||||
|
|
@ -988,7 +989,7 @@
|
|||
fakednsModal.show({
|
||||
title: '{{ i18n "pages.xray.fakedns.add" }}',
|
||||
confirm: (item) => {
|
||||
fakeDns = this.fakeDns ?? [];
|
||||
const fakeDns = this.fakeDns ?? [];
|
||||
fakeDns.push(item);
|
||||
this.fakeDns = fakeDns;
|
||||
fakednsModal.close();
|
||||
|
|
@ -1001,7 +1002,7 @@
|
|||
title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index + 1),
|
||||
fakeDns: this.fakeDns[index],
|
||||
confirm: (item) => {
|
||||
fakeDns = this.fakeDns;
|
||||
const fakeDns = this.fakeDns;
|
||||
fakeDns[index] = item;
|
||||
this.fakeDns = fakeDns;
|
||||
fakednsModal.close();
|
||||
|
|
@ -1010,7 +1011,7 @@
|
|||
});
|
||||
},
|
||||
deleteFakedns(index) {
|
||||
fakeDns = this.fakeDns;
|
||||
const fakeDns = this.fakeDns;
|
||||
fakeDns.splice(index, 1);
|
||||
this.fakeDns = fakeDns;
|
||||
},
|
||||
|
|
@ -1045,13 +1046,13 @@
|
|||
});
|
||||
},
|
||||
replaceRule(old_index, new_index) {
|
||||
rules = this.templateSettings.routing.rules;
|
||||
const rules = this.templateSettings.routing.rules;
|
||||
if (new_index >= rules.length) rules.push(undefined);
|
||||
rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
|
||||
this.routingRuleSettings = JSON.stringify(rules);
|
||||
},
|
||||
deleteRule(index) {
|
||||
rules = this.templateSettings.routing.rules;
|
||||
const rules = this.templateSettings.routing.rules;
|
||||
rules.splice(index, 1);
|
||||
this.routingRuleSettings = JSON.stringify(rules);
|
||||
},
|
||||
|
|
@ -1101,7 +1102,7 @@
|
|||
inboundSettings: {
|
||||
get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.inbounds = JSON.parse(newValue);
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
|
|
@ -1109,14 +1110,14 @@
|
|||
outboundSettings: {
|
||||
get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.outbounds = JSON.parse(newValue);
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
},
|
||||
outboundData: {
|
||||
get: function () {
|
||||
data = []
|
||||
const data = [];
|
||||
if (this.templateSettings != null) {
|
||||
this.templateSettings.outbounds.forEach((o, index) => {
|
||||
data.push({ 'key': index, ...o });
|
||||
|
|
@ -1127,7 +1128,7 @@
|
|||
},
|
||||
reverseData: {
|
||||
get: function () {
|
||||
data = []
|
||||
const data = [];
|
||||
if (this.templateSettings != null && this.templateSettings.reverse != null) {
|
||||
if (this.templateSettings.reverse.bridges) {
|
||||
this.templateSettings.reverse.bridges.forEach((o, index) => {
|
||||
|
|
@ -1146,14 +1147,14 @@
|
|||
routingRuleSettings: {
|
||||
get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.routing.rules = JSON.parse(newValue);
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
},
|
||||
routingRuleData: {
|
||||
get: function () {
|
||||
data = [];
|
||||
const data = [];
|
||||
if (this.templateSettings != null) {
|
||||
this.templateSettings.routing.rules.forEach((r, index) => {
|
||||
data.push({ 'key': index, ...r });
|
||||
|
|
@ -1174,7 +1175,7 @@
|
|||
},
|
||||
balancersData: {
|
||||
get: function () {
|
||||
data = []
|
||||
const data = [];
|
||||
if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
|
||||
this.templateSettings.routing.balancers.forEach((o, index) => {
|
||||
data.push({
|
||||
|
|
@ -1194,7 +1195,7 @@
|
|||
return this.templateSettings?.observatory ? JSON.stringify(this.templateSettings.observatory, null, 2) : null;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.observatory = JSON.parse(newValue);
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
|
|
@ -1204,7 +1205,7 @@
|
|||
return this.templateSettings?.burstObservatory ? JSON.stringify(this.templateSettings.burstObservatory, null, 2) : null;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.burstObservatory = JSON.parse(newValue);
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
|
|
@ -1214,14 +1215,14 @@
|
|||
freedomStrategy: {
|
||||
get: function () {
|
||||
if (!this.templateSettings) return "AsIs";
|
||||
freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
|
||||
const freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
|
||||
if (!freedomOutbound) return "AsIs";
|
||||
if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
|
||||
return freedomOutbound.settings.domainStrategy;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
const freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
|
||||
if (freedomOutboundIndex == -1) {
|
||||
newTemplateSettings.outbounds.push({ protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue } });
|
||||
} else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
|
||||
|
|
@ -1238,7 +1239,7 @@
|
|||
return this.templateSettings.routing.domainStrategy;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.routing.domainStrategy = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1249,7 +1250,7 @@
|
|||
return this.templateSettings.log.loglevel;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.log.loglevel = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1260,7 +1261,7 @@
|
|||
return this.templateSettings.log.access;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.log.access = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1271,7 +1272,7 @@
|
|||
return this.templateSettings.log.error;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.log.error = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1282,7 +1283,7 @@
|
|||
return this.templateSettings.log.dnsLog;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.log.dnsLog = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1293,7 +1294,7 @@
|
|||
return this.templateSettings.policy.system.statsInboundUplink;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.policy.system.statsInboundUplink = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1304,7 +1305,7 @@
|
|||
return this.templateSettings.policy.system.statsInboundDownlink;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.policy.system.statsInboundDownlink = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1315,7 +1316,7 @@
|
|||
return this.templateSettings.policy.system.statsOutboundUplink;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.policy.system.statsOutboundUplink = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1326,7 +1327,7 @@
|
|||
return this.templateSettings.policy.system.statsOutboundDownlink;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.policy.system.statsOutboundDownlink = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1337,7 +1338,7 @@
|
|||
return this.templateSettings.log.maskAddress;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.log.maskAddress = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1423,7 +1424,7 @@
|
|||
return this.templateSettings ? this.templateSettings.dns != null : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns = {
|
||||
servers: [],
|
||||
|
|
@ -1444,7 +1445,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.tag : "";
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.dns.tag = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1454,7 +1455,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.clientIp : null;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.clientIp = newValue;
|
||||
} else {
|
||||
|
|
@ -1468,7 +1469,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.disableCache : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.disableCache = newValue;
|
||||
} else {
|
||||
|
|
@ -1482,7 +1483,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.disableFallback : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.disableFallback = newValue;
|
||||
} else {
|
||||
|
|
@ -1496,7 +1497,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.disableFallbackIfMatch : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.disableFallbackIfMatch = newValue;
|
||||
} else {
|
||||
|
|
@ -1510,7 +1511,7 @@
|
|||
return this.enableDNS ? (this.templateSettings.dns.enableParallelQuery || false) : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.enableParallelQuery = newValue;
|
||||
} else {
|
||||
|
|
@ -1524,7 +1525,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.useSystemHosts : false;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (newValue) {
|
||||
newTemplateSettings.dns.useSystemHosts = newValue;
|
||||
} else {
|
||||
|
|
@ -1538,7 +1539,7 @@
|
|||
return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
|
||||
},
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.dns.queryStrategy = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1546,7 +1547,7 @@
|
|||
dnsServers: {
|
||||
get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
newTemplateSettings.dns.servers = newValue;
|
||||
this.templateSettings = newTemplateSettings;
|
||||
}
|
||||
|
|
@ -1554,7 +1555,7 @@
|
|||
fakeDns: {
|
||||
get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
|
||||
set: function (newValue) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
const newTemplateSettings = this.templateSettings;
|
||||
if (this.enableDNS) {
|
||||
newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue