diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2024-03-11 10:36:33 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2024-03-11 10:57:43 +0300 |
| commit | d18eb7e4e45306ee09fcd60c3d589da5197b626a (patch) | |
| tree | 5447cfea8583cc72e7645866dd9ca64830ad405e /web/assets/js/model/outbound.js | |
| parent | d3377cd45effb3f95bb5b1023fd4d386d8c2e469 (diff) | |
New - HttpUpgrade Transport
Diffstat (limited to 'web/assets/js/model/outbound.js')
| -rw-r--r-- | web/assets/js/model/outbound.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index 05248b77..c5b0348b 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -268,6 +268,28 @@ class GrpcStreamSettings extends CommonClass { } } +class HttpUpgradeStreamSettings extends CommonClass { + constructor(path='/', host='') { + super(); + this.path = path; + this.host = host; + } + + static fromJson(json={}) { + return new HttpUpgradeStreamSettings( + json.path, + json.Host, + ); + } + + toJson() { + return { + path: this.path, + host: this.host, + }; + } +} + class TlsStreamSettings extends CommonClass { constructor(serverName='', alpn=[], @@ -339,6 +361,7 @@ class StreamSettings extends CommonClass { httpSettings=new HttpStreamSettings(), quicSettings=new QuicStreamSettings(), grpcSettings=new GrpcStreamSettings(), + httpupgradeSettings=new HttpUpgradeStreamSettings(), ) { super(); this.network = network; @@ -351,6 +374,7 @@ class StreamSettings extends CommonClass { this.http = httpSettings; this.quic = quicSettings; this.grpc = grpcSettings; + this.httpupgrade = httpupgradeSettings; } get isTls() { @@ -373,6 +397,7 @@ class StreamSettings extends CommonClass { HttpStreamSettings.fromJson(json.httpSettings), QuicStreamSettings.fromJson(json.quicSettings), GrpcStreamSettings.fromJson(json.grpcSettings), + HttpUpgradeStreamSettings.fromJson(json.httpupgradeSettings), ); } @@ -389,6 +414,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, + httpupgradeSettings: network === 'httpupgrade' ? this.httpupgrade.toJson() : undefined, }; } } @@ -419,7 +445,7 @@ class Outbound extends CommonClass { canEnableTls() { if (![Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(this.protocol)) return false; - return ["tcp", "ws", "http", "quic", "grpc"].includes(this.stream.network); + return ["tcp", "ws", "http", "quic", "grpc", "httpupgrade"].includes(this.stream.network); } //this is used for xtls-rprx-vision @@ -523,6 +549,8 @@ class Outbound extends CommonClass { json.type ? json.type : 'none'); } else if (network === 'grpc') { stream.grpc = new GrpcStreamSettings(json.path, json.type == 'multi'); + } else if (network === 'httpupgrade') { + stream.httpupgrade = new HttpUpgradeStreamSettings(json.path,json.host); } if(json.tls && json.tls == 'tls'){ @@ -564,6 +592,8 @@ class Outbound extends CommonClass { headerType ?? 'none'); } else if (type === 'grpc') { stream.grpc = new GrpcStreamSettings(url.searchParams.get('serviceName') ?? '', url.searchParams.get('mode') == 'multi'); + } else if (type === 'httpupgrade') { + stream.httpupgrade = new HttpUpgradeStreamSettings(path,host); } if(security == 'tls'){ |
