From 100bd29c9251563eb70365a530cfa5eb677de2a3 Mon Sep 17 00:00:00 2001 From: GSWXXN <819269088@qq.com> Date: Sun, 22 Aug 2021 16:20:22 +0800 Subject: [PATCH] add flow control mode for trojan Signed-off-by: GSWXXN <819269088@qq.com> --- web/assets/js/model/xray.js | 19 +++++++++++++------ web/html/xui/form/protocol/trojan.html | 6 ++++++ web/html/xui/form/protocol/vless.html | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index b9c0f2e9..077343a8 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -40,7 +40,7 @@ const RULE_DOMAIN = { SPEEDTEST: 'geosite:speedtest', }; -const VLESS_FLOW = { +const FLOW_CONTROL = { ORIGIN: "xtls-rprx-origin", DIRECT: "xtls-rprx-direct", }; @@ -50,7 +50,7 @@ Object.freeze(VmessMethods); Object.freeze(SSMethods); Object.freeze(RULE_IP); Object.freeze(RULE_DOMAIN); -Object.freeze(VLESS_FLOW); +Object.freeze(FLOW_CONTROL); class XrayCommonClass { @@ -697,11 +697,13 @@ class Inbound extends XrayCommonClass { } } - // VLess + // VLess & Trojan get flow() { switch (this.protocol) { case Protocols.VLESS: return this.settings.vlesses[0].flow; + case Protocols.TROJAN: + return this.settings.clients[0].flow; default: return ""; } @@ -1217,7 +1219,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { }; Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { - constructor(id=RandomUtil.randomUUID(), flow=VLESS_FLOW.DIRECT) { + constructor(id=RandomUtil.randomUUID(), flow=FLOW_CONTROL.DIRECT) { super(); this.id = id; this.flow = flow; @@ -1305,19 +1307,24 @@ Inbound.TrojanSettings = class extends Inbound.Settings { } }; Inbound.TrojanSettings.Client = class extends XrayCommonClass { - constructor(password=RandomUtil.randomSeq(10)) { + constructor(password=RandomUtil.randomSeq(10), flow=FLOW_CONTROL.DIRECT) { super(); this.password = password; + this.flow = flow; } toJson() { return { password: this.password, + flow: this.flow, }; } static fromJson(json={}) { - return new Inbound.TrojanSettings.Client(json.password); + return new Inbound.TrojanSettings.Client( + json.password, + json.flow, + ); } }; diff --git a/web/html/xui/form/protocol/trojan.html b/web/html/xui/form/protocol/trojan.html index 78c98191..66c24c84 100644 --- a/web/html/xui/form/protocol/trojan.html +++ b/web/html/xui/form/protocol/trojan.html @@ -3,6 +3,12 @@ + + + + [[ key ]] + + diff --git a/web/html/xui/form/protocol/vless.html b/web/html/xui/form/protocol/vless.html index 567a1bd0..3e5a3a38 100644 --- a/web/html/xui/form/protocol/vless.html +++ b/web/html/xui/form/protocol/vless.html @@ -6,7 +6,7 @@ - [[ key ]] + [[ key ]]