new - acceptProxyProtocol for H2 and gRPC #581

This commit is contained in:
MHSanaei 2023-06-09 18:53:57 +03:30
parent 9063336778
commit dea61b839c
4 changed files with 26 additions and 7 deletions

View file

@ -378,10 +378,15 @@ class WsStreamSettings extends XrayCommonClass {
} }
class HttpStreamSettings extends XrayCommonClass { class HttpStreamSettings extends XrayCommonClass {
constructor(path='/', host=['']) { constructor(
path='/',
host=[''],
sockopt={acceptProxyProtocol: false}
) {
super(); super();
this.path = path; this.path = path;
this.host = host.length === 0 ? [''] : host; this.host = host.length === 0 ? [''] : host;
this.sockopt = sockopt;
} }
addHost(host) { addHost(host) {
@ -393,7 +398,7 @@ class HttpStreamSettings extends XrayCommonClass {
} }
static fromJson(json={}) { static fromJson(json={}) {
return new HttpStreamSettings(json.path, json.host); return new HttpStreamSettings(json.path, json.host, json.sockopt);
} }
toJson() { toJson() {
@ -406,10 +411,12 @@ class HttpStreamSettings extends XrayCommonClass {
return { return {
path: this.path, path: this.path,
host: host, host: host,
sockopt: this.sockopt,
} }
} }
} }
class QuicStreamSettings extends XrayCommonClass { class QuicStreamSettings extends XrayCommonClass {
constructor(security=VmessMethods.NONE, constructor(security=VmessMethods.NONE,
key='', type='none') { key='', type='none') {
@ -441,28 +448,33 @@ class QuicStreamSettings extends XrayCommonClass {
class GrpcStreamSettings extends XrayCommonClass { class GrpcStreamSettings extends XrayCommonClass {
constructor( constructor(
serviceName="", serviceName="",
multiMode=false multiMode=false,
sockopt={acceptProxyProtocol: false}
) { ) {
super(); super();
this.serviceName = serviceName; this.serviceName = serviceName;
this.multiMode = multiMode; this.multiMode = multiMode;
this.sockopt = sockopt;
} }
static fromJson(json={}) { static fromJson(json={}) {
return new GrpcStreamSettings( return new GrpcStreamSettings(
json.serviceName, json.serviceName,
json.multiMode json.multiMode,
json.sockopt
); );
} }
toJson() { toJson() {
return { return {
serviceName: this.serviceName, serviceName: this.serviceName,
multiMode: this.multiMode multiMode: this.multiMode,
sockopt: this.sockopt
} }
} }
} }
class TlsStreamSettings extends XrayCommonClass { class TlsStreamSettings extends XrayCommonClass {
constructor(serverName='', constructor(serverName='',
minVersion = TLS_VERSION_OPTION.TLS12, minVersion = TLS_VERSION_OPTION.TLS12,

View file

@ -1,5 +1,9 @@
{{define "form/streamGRPC"}} {{define "form/streamGRPC"}}
<a-form layout="inline"> <a-form layout="inline">
<a-form-item label="AcceptProxyProtocol">
<a-switch v-model="inbound.stream.grpc.sockopt.acceptProxyProtocol"></a-switch>
</a-form-item>
<br>
<a-form-item label="ServiceName"> <a-form-item label="ServiceName">
<a-input v-model.trim="inbound.stream.grpc.serviceName"></a-input> <a-input v-model.trim="inbound.stream.grpc.serviceName"></a-input>
</a-form-item> </a-form-item>

View file

@ -1,5 +1,9 @@
{{define "form/streamHTTP"}} {{define "form/streamHTTP"}}
<a-form layout="inline"> <a-form layout="inline">
<a-form-item label="AcceptProxyProtocol">
<a-switch v-model="inbound.stream.http.sockopt.acceptProxyProtocol"></a-switch>
</a-form-item>
<br>
<a-form-item label='{{ i18n "path" }}'> <a-form-item label='{{ i18n "path" }}'>
<a-input v-model.trim="inbound.stream.http.path"></a-input> <a-input v-model.trim="inbound.stream.http.path"></a-input>
</a-form-item> </a-form-item>

View file

@ -3,8 +3,7 @@
<a-form-item label="AcceptProxyProtocol"> <a-form-item label="AcceptProxyProtocol">
<a-switch v-model="inbound.stream.ws.acceptProxyProtocol"></a-switch> <a-switch v-model="inbound.stream.ws.acceptProxyProtocol"></a-switch>
</a-form-item> </a-form-item>
</a-form> <br>
<a-form layout="inline">
<a-form-item label='{{ i18n "path" }}'> <a-form-item label='{{ i18n "path" }}'>
<a-input v-model.trim="inbound.stream.ws.path"></a-input> <a-input v-model.trim="inbound.stream.ws.path"></a-input>
</a-form-item> </a-form-item>