From 77d844460a3a75a4469ee8aebb3dff76fc9cd8a5 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 27 Apr 2022 23:27:32 +0800 Subject: [PATCH] fix fallback bug --- .gitignore | 3 ++- go.mod | 2 +- web/assets/js/model/xray.js | 24 +++++++++++------------- web/html/xui/form/stream/stream_tcp.html | 3 +++ web/html/xui/form/stream/stream_ws.html | 5 +++++ web/html/xui/form/tls_settings.html | 5 +++++ 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 54c663a..1b5f006 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ dist/ x-ui-*.tar.gz /x-ui /release.sh -.sync* \ No newline at end of file +.sync* +main diff --git a/go.mod b/go.mod index 4e8d00d..44b6570 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/gin-contrib/sessions v0.0.3 github.com/gin-gonic/gin v1.7.1 github.com/go-ole/go-ole v1.2.5 // indirect - github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect + github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 github.com/nicksnyder/go-i18n/v2 v2.1.2 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/robfig/cron/v3 v3.0.1 diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 7742fa7..16dfee6 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -110,11 +110,13 @@ class XrayCommonClass { } class TcpStreamSettings extends XrayCommonClass { - constructor(type='none', + constructor(acceptProxyProtocol=false, + type='none', request=new TcpStreamSettings.TcpRequest(), response=new TcpStreamSettings.TcpResponse(), ) { super(); + this.acceptProxyProtocol = acceptProxyProtocol; this.type = type; this.request = request; this.response = response; @@ -125,7 +127,7 @@ class TcpStreamSettings extends XrayCommonClass { if (!header) { header = {}; } - return new TcpStreamSettings( + return new TcpStreamSettings(json.acceptProxyProtocol, header.type, TcpStreamSettings.TcpRequest.fromJson(header.request), TcpStreamSettings.TcpResponse.fromJson(header.response), @@ -134,6 +136,7 @@ class TcpStreamSettings extends XrayCommonClass { toJson() { return { + acceptProxyProtocol: this.acceptProxyProtocol, header: { type: this.type, request: this.type === 'http' ? this.request.toJson() : undefined, @@ -293,8 +296,9 @@ class KcpStreamSettings extends XrayCommonClass { } class WsStreamSettings extends XrayCommonClass { - constructor(path='/', headers=[]) { + constructor(acceptProxyProtocol=false, path='/', headers=[]) { super(); + this.acceptProxyProtocol = acceptProxyProtocol; this.path = path; this.headers = headers; } @@ -318,6 +322,7 @@ class WsStreamSettings extends XrayCommonClass { static fromJson(json={}) { return new WsStreamSettings( + json.acceptProxyProtocol, json.path, XrayCommonClass.toHeaders(json.headers), ); @@ -325,6 +330,7 @@ class WsStreamSettings extends XrayCommonClass { toJson() { return { + acceptProxyProtocol: this.acceptProxyProtocol, path: this.path, headers: XrayCommonClass.toV2Headers(this.headers, false), }; @@ -629,11 +635,7 @@ class Inbound extends XrayCommonClass { if (isTls) { this.stream.security = 'tls'; } else { - if (this.protocol === Protocols.TROJAN) { - this.xtls = true; - } else { - this.stream.security = 'none'; - } + this.stream.security = 'none'; } } @@ -645,11 +647,7 @@ class Inbound extends XrayCommonClass { if (isXTls) { this.stream.security = 'xtls'; } else { - if (this.protocol === Protocols.TROJAN) { - this.tls = true; - } else { - this.stream.security = 'none'; - } + this.stream.security = 'none'; } } diff --git a/web/html/xui/form/stream/stream_tcp.html b/web/html/xui/form/stream/stream_tcp.html index de9ce07..30931fb 100644 --- a/web/html/xui/form/stream/stream_tcp.html +++ b/web/html/xui/form/stream/stream_tcp.html @@ -1,6 +1,9 @@ {{define "form/streamTCP"}} + + + + + + + diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html index 474d1f2..6244ce3 100644 --- a/web/html/xui/form/tls_settings.html +++ b/web/html/xui/form/tls_settings.html @@ -42,4 +42,9 @@ + + + + + {{end}} \ No newline at end of file