From 4fdef3cfde47a5febe969f7223ddd49800dcd7a4 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 24 Sep 2024 11:38:10 +0200 Subject: add or remove noise --- web/html/xui/form/outbound.html | 42 ++++++++---- web/html/xui/form/stream/stream_splithttp.html | 12 ++-- web/html/xui/settings.html | 92 +++++++++++++++----------- 3 files changed, 90 insertions(+), 56 deletions(-) (limited to 'web/html') diff --git a/web/html/xui/form/outbound.html b/web/html/xui/form/outbound.html index 21fedd88..bbad5c85 100644 --- a/web/html/xui/form/outbound.html +++ b/web/html/xui/form/outbound.html @@ -46,21 +46,39 @@ + + - + + - diff --git a/web/html/xui/form/stream/stream_splithttp.html b/web/html/xui/form/stream/stream_splithttp.html index f03a039c..453263de 100644 --- a/web/html/xui/form/stream/stream_splithttp.html +++ b/web/html/xui/form/stream/stream_splithttp.html @@ -34,17 +34,17 @@ - - - - + + + + - + - + {{end}} diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html index b95ce0a5..4ffbb0b7 100644 --- a/web/html/xui/settings.html +++ b/web/html/xui/settings.html @@ -314,23 +314,29 @@ - + - - [[ p ]] + + + [[ p ]] - - + + + Remove + Add Noise @@ -436,11 +442,9 @@ protocol: "freedom", settings: { domainStrategy: "AsIs", - noises: { - type: "rand", - packet: "10-20", - delay: "10-16", - } + noises: [ + { type: "rand", packet: "10-20", delay: "10-16" }, + ], }, }, defaultMux: { @@ -604,6 +608,30 @@ this.user.loginSecret = ""; } }, + addNoise() { + const newNoise = { type: "rand", packet: "10-20", delay: "10-16" }; + this.noisesArray = [...this.noisesArray, newNoise]; + }, + removeNoise(index) { + const newNoises = [...this.noisesArray]; + newNoises.splice(index, 1); + this.noisesArray = newNoises; + }, + updateNoiseType(index, value) { + const updatedNoises = [...this.noisesArray]; + updatedNoises[index] = { ...updatedNoises[index], type: value }; + this.noisesArray = updatedNoises; + }, + updateNoisePacket(index, value) { + const updatedNoises = [...this.noisesArray]; + updatedNoises[index] = { ...updatedNoises[index], packet: value }; + this.noisesArray = updatedNoises; + }, + updateNoiseDelay(index, value) { + const updatedNoises = [...this.noisesArray]; + updatedNoises[index] = { ...updatedNoises[index], delay: value }; + this.noisesArray = updatedNoises; + }, }, computed: { fragment: { @@ -643,37 +671,25 @@ } }, noises: { - get: function () { return this.allSetting?.subJsonNoises != ""; }, - set: function (v) { - this.allSetting.subJsonNoises = v ? JSON.stringify(this.defaultNoises) : ""; - } - }, - noisesType: { - get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.type : ""; }, - set: function (v) { - if (v != "") { - newNoises = JSON.parse(this.allSetting.subJsonNoises); - newNoises.settings.noises.type = v; - this.allSetting.subJsonNoises = JSON.stringify(newNoises); - } - } - }, - noisesPacket: { - get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.packet : ""; }, - set: function (v) { - if (v != "") { - newNoises = JSON.parse(this.allSetting.subJsonNoises); - newNoises.settings.noises.packet = v; - this.allSetting.subJsonNoises = JSON.stringify(newNoises); + get() { + return this.allSetting?.subJsonNoises != ""; + }, + set(v) { + if (v) { + this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises); + } else { + this.allSetting.subJsonNoises = ""; } } }, - noisesDelay: { - get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.delay : ""; }, - set: function (v) { - if (v != "") { - newNoises = JSON.parse(this.allSetting.subJsonNoises); - newNoises.settings.noises.delay = v; + noisesArray: { + get() { + return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises : []; + }, + set(value) { + if (this.noises) { + const newNoises = JSON.parse(this.allSetting.subJsonNoises); + newNoises.settings.noises = value; this.allSetting.subJsonNoises = JSON.stringify(newNoises); } } -- cgit v1.2.3