From fe22cbd0e5a87da4c99a2bd075d6858f74da98cc Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 26 Aug 2023 15:39:18 +0330 Subject: [PATCH] Transparent Proxy with sockopt Stream Setting Co-Authored-By: Alireza Ahmadi --- web/assets/js/model/xray.js | 29 ++++++----- web/html/xui/form/stream/stream_grpc.html | 4 -- web/html/xui/form/stream/stream_http.html | 4 -- web/html/xui/form/stream/stream_settings.html | 5 ++ web/html/xui/form/stream/stream_sockopt.html | 48 +++++++++++++++++++ 5 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 web/html/xui/form/stream/stream_sockopt.html diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index fff71e8b..8ab2969d 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -803,22 +803,27 @@ RealityStreamSettings.Settings = class extends XrayCommonClass { }; class SockoptStreamSettings extends XrayCommonClass { - constructor( - acceptProxyProtocol = false, - ) { + constructor(acceptProxyProtocol = false, tcpFastOpen = false, mark = 0, tproxy="off") { super(); this.acceptProxyProtocol = acceptProxyProtocol; + this.tcpFastOpen = tcpFastOpen; + this.mark = mark; + this.tproxy = tproxy; } - static fromJson(json = {}) { return new SockoptStreamSettings( json.acceptProxyProtocol, + json.tcpFastOpen, + json.mark, + json.tproxy, ); } - toJson() { return { acceptProxyProtocol: this.acceptProxyProtocol, + tcpFastOpen: this.tcpFastOpen, + mark: this.mark, + tproxy: this.tproxy, }; } } @@ -835,7 +840,7 @@ class StreamSettings extends XrayCommonClass { httpSettings=new HttpStreamSettings(), quicSettings=new QuicStreamSettings(), grpcSettings=new GrpcStreamSettings(), - sockopt = new SockoptStreamSettings(), + sockopt = undefined, ) { super(); this.network = network; @@ -889,14 +894,12 @@ class StreamSettings extends XrayCommonClass { } } - get isSockopt() { - return ['http', 'grpc'].indexOf(this.network) !== -1; + get sockoptSwitch() { + return this.sockopt != undefined; } - set isSockopt(isSockopt) { - if (isSockopt) { - return ['http', 'grpc'].indexOf(this.network) !== -1; - } + set sockoptSwitch(value) { + this.sockopt = value ? new SockoptStreamSettings() : undefined; } static fromJson(json={}) { @@ -931,7 +934,7 @@ class StreamSettings extends XrayCommonClass { httpSettings: network === 'http' ? this.http.toJson() : undefined, quicSettings: network === 'quic' ? this.quic.toJson() : undefined, grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined, - sockopt: this.isSockopt ? this.sockopt.toJson() : undefined, + sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined, }; } } diff --git a/web/html/xui/form/stream/stream_grpc.html b/web/html/xui/form/stream/stream_grpc.html index 1ee57bbf..21c95f99 100644 --- a/web/html/xui/form/stream/stream_grpc.html +++ b/web/html/xui/form/stream/stream_grpc.html @@ -1,9 +1,5 @@ {{define "form/streamGRPC"}} - - - -
diff --git a/web/html/xui/form/stream/stream_http.html b/web/html/xui/form/stream/stream_http.html index e80eef0f..57574ce5 100644 --- a/web/html/xui/form/stream/stream_http.html +++ b/web/html/xui/form/stream/stream_http.html @@ -1,9 +1,5 @@ {{define "form/streamHTTP"}} - - - -
diff --git a/web/html/xui/form/stream/stream_settings.html b/web/html/xui/form/stream/stream_settings.html index 4a07947e..e50caf19 100644 --- a/web/html/xui/form/stream/stream_settings.html +++ b/web/html/xui/form/stream/stream_settings.html @@ -42,4 +42,9 @@ + + + {{end}} \ No newline at end of file diff --git a/web/html/xui/form/stream/stream_sockopt.html b/web/html/xui/form/stream/stream_sockopt.html new file mode 100644 index 00000000..d4019054 --- /dev/null +++ b/web/html/xui/form/stream/stream_sockopt.html @@ -0,0 +1,48 @@ +{{define "form/streamSockopt"}} + + + + + + + + + + + + + + + + + + + + + + + +
Accept Proxy Protocol + + + +
TCP FastOpen + + + +
Route Mark + + + +
T-Proxy + + + OFF + Redirect + T-Proxy + + +
+
+{{end}} \ No newline at end of file