diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index bc4ad735..5772d34f 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -854,7 +854,7 @@ Outbound.FreedomSettings = class extends CommonClass { timeout = 10, redirect = '', fragment = {}, - noises = {} + noises = [] ) { super(); this.domainStrategy = domainStrategy; @@ -864,13 +864,21 @@ Outbound.FreedomSettings = class extends CommonClass { this.noises = noises; } + addNoise() { + this.noises.push(new Outbound.FreedomSettings.Noise()); + } + + delNoise(index) { + this.noises.splice(index, 1); + } + static fromJson(json = {}) { return new Outbound.FreedomSettings( json.domainStrategy, json.timeout, json.redirect, json.fragment ? Outbound.FreedomSettings.Fragment.fromJson(json.fragment) : undefined, - json.noises ? Outbound.FreedomSettings.Noises.fromJson(json.noises) : undefined, + json.noises ? json.noises.map(noise => Outbound.FreedomSettings.Noise.fromJson(noise)) : [new Outbound.FreedomSettings.Noise()], ); } @@ -880,10 +888,11 @@ Outbound.FreedomSettings = class extends CommonClass { timeout: this.timeout, redirect: this.redirect, fragment: Object.keys(this.fragment).length === 0 ? undefined : this.fragment, - noises: Object.keys(this.noises).length === 0 ? undefined : this.noises, + noises: Outbound.FreedomSettings.Noise.toJsonArray(this.noises), }; } }; + Outbound.FreedomSettings.Fragment = class extends CommonClass { constructor(packets = '1-3', length = '', interval = '') { super(); @@ -900,7 +909,8 @@ Outbound.FreedomSettings.Fragment = class extends CommonClass { ); } }; -Outbound.FreedomSettings.Noises = class extends CommonClass { + +Outbound.FreedomSettings.Noise = class extends CommonClass { constructor( type = 'rand', packet = '10-20', @@ -913,12 +923,24 @@ Outbound.FreedomSettings.Noises = class extends CommonClass { } static fromJson(json = {}) { - return new Outbound.FreedomSettings.Noises( + return new Outbound.FreedomSettings.Noise( json.type, json.packet, json.delay, ); } + + toJson() { + return { + type: this.type, + packet: this.packet, + delay: this.delay, + }; + } + + static toJsonArray(noises) { + return noises.map(noise => noise.toJson()); + } }; Outbound.BlackholeSettings = class extends CommonClass { diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 93c3ac1e..74211952 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -530,10 +530,10 @@ class SplitHTTPStreamSettings extends XrayCommonClass { noSSEHeader = false, xPaddingBytes = "100-1000", xmux = { - maxConnections: 0, - maxConcurrency: 0, - cMaxReuseTimes: 0, - cMaxLifetimeMs: 0 + maxConcurrency: 0, + maxConnections: 0, + cMaxReuseTimes: 0, + cMaxLifetimeMs: 0 } ) { super(); @@ -581,8 +581,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass { noSSEHeader: this.noSSEHeader, xPaddingBytes: this.xPaddingBytes, xmux: { - maxConnections: this.xmux.maxConnections, maxConcurrency: this.xmux.maxConcurrency, + maxConnections: this.xmux.maxConnections, cMaxReuseTimes: this.xmux.cMaxReuseTimes, cMaxLifetimeMs: this.xmux.cMaxLifetimeMs } 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); + get() { + return this.allSetting?.subJsonNoises != ""; + }, + set(v) { + if (v) { + this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises); + } else { + this.allSetting.subJsonNoises = ""; } } }, - 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); - } - } - }, - 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); } } diff --git a/web/service/config.json b/web/service/config.json index 3f7fbc3a..122963fe 100644 --- a/web/service/config.json +++ b/web/service/config.json @@ -2,8 +2,9 @@ "log": { "access": "none", "dnsLog": false, - "error": "./error.log", - "loglevel": "warning" + "error": "", + "loglevel": "warning", + "maskAddress": "" }, "api": { "tag": "api",