diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index a790e28b..f67528c2 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -333,7 +333,36 @@ class RealityStreamSettings extends CommonClass { spiderX: this.spiderX, }; } -}; +} + +class SockoptStreamSettings extends CommonClass { + constructor(dialerProxy = "", tcpFastOpen = false, tcpKeepAliveInterval = 0, tcpNoDelay = false) { + super(); + this.dialerProxy = dialerProxy; + this.tcpFastOpen = tcpFastOpen; + this.tcpKeepAliveInterval = tcpKeepAliveInterval; + this.tcpNoDelay = tcpNoDelay; + } + + static fromJson(json = {}) { + if (Object.keys(json).length === 0) return undefined; + return new SockoptStreamSettings( + json.dialerProxy, + json.tcpFastOpen, + json.tcpKeepAliveInterval, + json.tcpNoDelay, + ); + } + + toJson() { + return { + dialerProxy: this.dialerProxy, + tcpFastOpen: this.tcpFastOpen, + tcpKeepAliveInterval: this.tcpKeepAliveInterval, + tcpNoDelay: this.tcpNoDelay, + }; + } +} class StreamSettings extends CommonClass { constructor(network='tcp', @@ -346,6 +375,7 @@ class StreamSettings extends CommonClass { httpSettings=new HttpStreamSettings(), quicSettings=new QuicStreamSettings(), grpcSettings=new GrpcStreamSettings(), + sockopt = undefined, ) { super(); this.network = network; @@ -358,6 +388,7 @@ class StreamSettings extends CommonClass { this.http = httpSettings; this.quic = quicSettings; this.grpc = grpcSettings; + this.sockopt = sockopt; } get isTls() { @@ -368,6 +399,14 @@ class StreamSettings extends CommonClass { return this.security === "reality"; } + get sockoptSwitch() { + return this.sockopt != undefined; + } + + set sockoptSwitch(value) { + this.sockopt = value ? new SockoptStreamSettings() : undefined; + } + static fromJson(json={}) { return new StreamSettings( json.network, @@ -380,6 +419,7 @@ class StreamSettings extends CommonClass { HttpStreamSettings.fromJson(json.httpSettings), QuicStreamSettings.fromJson(json.quicSettings), GrpcStreamSettings.fromJson(json.grpcSettings), + SockoptStreamSettings.fromJson(json.sockopt), ); } @@ -396,6 +436,7 @@ class StreamSettings extends CommonClass { httpSettings: network === 'http' ? this.http.toJson() : undefined, quicSettings: network === 'quic' ? this.quic.toJson() : undefined, grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined, + sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined, }; } } diff --git a/web/html/xui/form/outbound.html b/web/html/xui/form/outbound.html index 5843ab4a..dfd0ec8f 100644 --- a/web/html/xui/form/outbound.html +++ b/web/html/xui/form/outbound.html @@ -214,17 +214,17 @@ + + +