Skip to content

Commit

Permalink
Merge pull request vaxilu#165 from KerryJi/feature/dev
Browse files Browse the repository at this point in the history
fix fallback bug
  • Loading branch information
vaxilu committed Apr 28, 2022
2 parents d350728 + e5d08bb commit 9c1be8c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist/
x-ui-*.tar.gz
/x-ui
/release.sh
.sync*
.sync*
main
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions web/assets/js/model/xray.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -318,13 +322,15 @@ class WsStreamSettings extends XrayCommonClass {

static fromJson(json={}) {
return new WsStreamSettings(
json.acceptProxyProtocol,
json.path,
XrayCommonClass.toHeaders(json.headers),
);
}

toJson() {
return {
acceptProxyProtocol: this.acceptProxyProtocol,
path: this.path,
headers: XrayCommonClass.toV2Headers(this.headers, false),
};
Expand Down Expand Up @@ -411,10 +417,11 @@ class GrpcStreamSettings extends XrayCommonClass {

class TlsStreamSettings extends XrayCommonClass {
constructor(serverName='',
certificates=[new TlsStreamSettings.Cert()]) {
certificates=[new TlsStreamSettings.Cert()], alpn=[]) {
super();
this.server = serverName;
this.certs = certificates;
this.alpn = alpn;
}

addCert(cert) {
Expand All @@ -430,16 +437,19 @@ class TlsStreamSettings extends XrayCommonClass {
if (!ObjectUtil.isEmpty(json.certificates)) {
certs = json.certificates.map(cert => TlsStreamSettings.Cert.fromJson(cert));
}

return new TlsStreamSettings(
json.serverName,
certs,
json.alpn
);
}

toJson() {
return {
serverName: this.server,
certificates: TlsStreamSettings.toJsonArray(this.certs),
alpn: this.alpn
};
}
}
Expand Down Expand Up @@ -629,11 +639,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';
}
}

Expand All @@ -645,11 +651,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';
}
}

Expand Down
3 changes: 3 additions & 0 deletions web/html/xui/form/stream/stream_tcp.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{{define "form/streamTCP"}}
<!-- tcp type -->
<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-switch
:checked="inbound.stream.tcp.type === 'http'"
Expand Down
5 changes: 5 additions & 0 deletions web/html/xui/form/stream/stream_ws.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{{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-item label="路径">
<a-input v-model.trim="inbound.stream.ws.path"></a-input>
Expand Down
8 changes: 8 additions & 0 deletions web/html/xui/form/tls_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<a-form-item label="域名">
<a-input v-model.trim="inbound.stream.tls.server"></a-input>
</a-form-item>
<a-form-item label="alpn" placeholder="http/1.1,h2">
<a-input v-model.trim="inbound.stream.tls.alpn"></a-input>
</a-form-item>
<a-form-item label="证书">
<a-radio-group v-model="inbound.stream.tls.certs[0].useFile"
button-style="solid">
Expand All @@ -42,4 +45,9 @@
</a-form-item>
</template>
</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}}

0 comments on commit 9c1be8c

Please sign in to comment.