fix fallback bug

This commit is contained in:
kerry
2022-04-27 23:27:32 +08:00
parent d3507286d6
commit 77d844460a
6 changed files with 27 additions and 15 deletions

3
.gitignore vendored
View File

@@ -6,4 +6,5 @@ dist/
x-ui-*.tar.gz x-ui-*.tar.gz
/x-ui /x-ui
/release.sh /release.sh
.sync* .sync*
main

2
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/gin-contrib/sessions v0.0.3 github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.1 github.com/gin-gonic/gin v1.7.1
github.com/go-ole/go-ole v1.2.5 // indirect 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/nicksnyder/go-i18n/v2 v2.1.2
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1

View File

@@ -110,11 +110,13 @@ class XrayCommonClass {
} }
class TcpStreamSettings extends XrayCommonClass { class TcpStreamSettings extends XrayCommonClass {
constructor(type='none', constructor(acceptProxyProtocol=false,
type='none',
request=new TcpStreamSettings.TcpRequest(), request=new TcpStreamSettings.TcpRequest(),
response=new TcpStreamSettings.TcpResponse(), response=new TcpStreamSettings.TcpResponse(),
) { ) {
super(); super();
this.acceptProxyProtocol = acceptProxyProtocol;
this.type = type; this.type = type;
this.request = request; this.request = request;
this.response = response; this.response = response;
@@ -125,7 +127,7 @@ class TcpStreamSettings extends XrayCommonClass {
if (!header) { if (!header) {
header = {}; header = {};
} }
return new TcpStreamSettings( return new TcpStreamSettings(json.acceptProxyProtocol,
header.type, header.type,
TcpStreamSettings.TcpRequest.fromJson(header.request), TcpStreamSettings.TcpRequest.fromJson(header.request),
TcpStreamSettings.TcpResponse.fromJson(header.response), TcpStreamSettings.TcpResponse.fromJson(header.response),
@@ -134,6 +136,7 @@ class TcpStreamSettings extends XrayCommonClass {
toJson() { toJson() {
return { return {
acceptProxyProtocol: this.acceptProxyProtocol,
header: { header: {
type: this.type, type: this.type,
request: this.type === 'http' ? this.request.toJson() : undefined, request: this.type === 'http' ? this.request.toJson() : undefined,
@@ -293,8 +296,9 @@ class KcpStreamSettings extends XrayCommonClass {
} }
class WsStreamSettings extends XrayCommonClass { class WsStreamSettings extends XrayCommonClass {
constructor(path='/', headers=[]) { constructor(acceptProxyProtocol=false, path='/', headers=[]) {
super(); super();
this.acceptProxyProtocol = acceptProxyProtocol;
this.path = path; this.path = path;
this.headers = headers; this.headers = headers;
} }
@@ -318,6 +322,7 @@ class WsStreamSettings extends XrayCommonClass {
static fromJson(json={}) { static fromJson(json={}) {
return new WsStreamSettings( return new WsStreamSettings(
json.acceptProxyProtocol,
json.path, json.path,
XrayCommonClass.toHeaders(json.headers), XrayCommonClass.toHeaders(json.headers),
); );
@@ -325,6 +330,7 @@ class WsStreamSettings extends XrayCommonClass {
toJson() { toJson() {
return { return {
acceptProxyProtocol: this.acceptProxyProtocol,
path: this.path, path: this.path,
headers: XrayCommonClass.toV2Headers(this.headers, false), headers: XrayCommonClass.toV2Headers(this.headers, false),
}; };
@@ -629,11 +635,7 @@ class Inbound extends XrayCommonClass {
if (isTls) { if (isTls) {
this.stream.security = 'tls'; this.stream.security = 'tls';
} else { } else {
if (this.protocol === Protocols.TROJAN) { this.stream.security = 'none';
this.xtls = true;
} else {
this.stream.security = 'none';
}
} }
} }
@@ -645,11 +647,7 @@ class Inbound extends XrayCommonClass {
if (isXTls) { if (isXTls) {
this.stream.security = 'xtls'; this.stream.security = 'xtls';
} else { } else {
if (this.protocol === Protocols.TROJAN) { this.stream.security = 'none';
this.tls = true;
} else {
this.stream.security = 'none';
}
} }
} }

View File

@@ -1,6 +1,9 @@
{{define "form/streamTCP"}} {{define "form/streamTCP"}}
<!-- tcp type --> <!-- tcp type -->
<a-form layout="inline"> <a-form layout="inline">
<a-form-item label="acceptProxyProtocol">
<a-switch v-model="inbound.stream.tcp.acceptProxyProtocol"></a-switch>
</a-form-item>
<a-form-item label="http 伪装"> <a-form-item label="http 伪装">
<a-switch <a-switch
:checked="inbound.stream.tcp.type === 'http'" :checked="inbound.stream.tcp.type === 'http'"

View File

@@ -1,4 +1,9 @@
{{define "form/streamWS"}} {{define "form/streamWS"}}
<a-form layout="inline">
<a-form-item label="acceptProxyProtocol">
<a-switch v-model="inbound.stream.ws.acceptProxyProtocol"></a-switch>
</a-form-item>
</a-form>
<a-form layout="inline"> <a-form layout="inline">
<a-form-item label="路径"> <a-form-item label="路径">
<a-input v-model.trim="inbound.stream.ws.path"></a-input> <a-input v-model.trim="inbound.stream.ws.path"></a-input>

View File

@@ -42,4 +42,9 @@
</a-form-item> </a-form-item>
</template> </template>
</a-form> </a-form>
<a-form layout="inline" v-else-if = "inbound.stream.network === 'tcp' ">
<a-form-item label="tcp-acceptProxyProtocol">
<a-switch v-model="inbound.stream.tcp.acceptProxyProtocol"></a-switch>
</a-form-item>
</a-form>
{{end}} {{end}}