mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-02 01:30:51 +03:00
Transparent Proxy with sockopt Stream Setting
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
parent
1277285d08
commit
fe22cbd0e5
@ -803,22 +803,27 @@ RealityStreamSettings.Settings = class extends XrayCommonClass {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class SockoptStreamSettings extends XrayCommonClass {
|
class SockoptStreamSettings extends XrayCommonClass {
|
||||||
constructor(
|
constructor(acceptProxyProtocol = false, tcpFastOpen = false, mark = 0, tproxy="off") {
|
||||||
acceptProxyProtocol = false,
|
|
||||||
) {
|
|
||||||
super();
|
super();
|
||||||
this.acceptProxyProtocol = acceptProxyProtocol;
|
this.acceptProxyProtocol = acceptProxyProtocol;
|
||||||
|
this.tcpFastOpen = tcpFastOpen;
|
||||||
|
this.mark = mark;
|
||||||
|
this.tproxy = tproxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJson(json = {}) {
|
static fromJson(json = {}) {
|
||||||
return new SockoptStreamSettings(
|
return new SockoptStreamSettings(
|
||||||
json.acceptProxyProtocol,
|
json.acceptProxyProtocol,
|
||||||
|
json.tcpFastOpen,
|
||||||
|
json.mark,
|
||||||
|
json.tproxy,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toJson() {
|
toJson() {
|
||||||
return {
|
return {
|
||||||
acceptProxyProtocol: this.acceptProxyProtocol,
|
acceptProxyProtocol: this.acceptProxyProtocol,
|
||||||
|
tcpFastOpen: this.tcpFastOpen,
|
||||||
|
mark: this.mark,
|
||||||
|
tproxy: this.tproxy,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -835,7 +840,7 @@ class StreamSettings extends XrayCommonClass {
|
|||||||
httpSettings=new HttpStreamSettings(),
|
httpSettings=new HttpStreamSettings(),
|
||||||
quicSettings=new QuicStreamSettings(),
|
quicSettings=new QuicStreamSettings(),
|
||||||
grpcSettings=new GrpcStreamSettings(),
|
grpcSettings=new GrpcStreamSettings(),
|
||||||
sockopt = new SockoptStreamSettings(),
|
sockopt = undefined,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.network = network;
|
this.network = network;
|
||||||
@ -889,14 +894,12 @@ class StreamSettings extends XrayCommonClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get isSockopt() {
|
get sockoptSwitch() {
|
||||||
return ['http', 'grpc'].indexOf(this.network) !== -1;
|
return this.sockopt != undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
set isSockopt(isSockopt) {
|
set sockoptSwitch(value) {
|
||||||
if (isSockopt) {
|
this.sockopt = value ? new SockoptStreamSettings() : undefined;
|
||||||
return ['http', 'grpc'].indexOf(this.network) !== -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJson(json={}) {
|
static fromJson(json={}) {
|
||||||
@ -931,7 +934,7 @@ class StreamSettings extends XrayCommonClass {
|
|||||||
httpSettings: network === 'http' ? this.http.toJson() : undefined,
|
httpSettings: network === 'http' ? this.http.toJson() : undefined,
|
||||||
quicSettings: network === 'quic' ? this.quic.toJson() : undefined,
|
quicSettings: network === 'quic' ? this.quic.toJson() : undefined,
|
||||||
grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined,
|
grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined,
|
||||||
sockopt: this.isSockopt ? this.sockopt.toJson() : undefined,
|
sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
{{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.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>
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
{{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.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>
|
||||||
|
@ -42,4 +42,9 @@
|
|||||||
<template v-if="inbound.stream.network === 'grpc'">
|
<template v-if="inbound.stream.network === 'grpc'">
|
||||||
{{template "form/streamGRPC"}}
|
{{template "form/streamGRPC"}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- sockopt -->
|
||||||
|
<template>
|
||||||
|
{{template "form/streamSockopt"}}
|
||||||
|
</template>
|
||||||
{{end}}
|
{{end}}
|
48
web/html/xui/form/stream/stream_sockopt.html
Normal file
48
web/html/xui/form/stream/stream_sockopt.html
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{{define "form/streamSockopt"}}
|
||||||
|
<a-form layout="inline">
|
||||||
|
<a-divider dashed style="margin:0;">
|
||||||
|
<a-form-item label="Transparent Proxy">
|
||||||
|
<a-switch v-model="inbound.stream.sockoptSwitch"></a-switch>
|
||||||
|
</a-form-item>
|
||||||
|
</a-divider>
|
||||||
|
<table width="100%" class="ant-table-tbody" v-if="inbound.stream.sockoptSwitch">
|
||||||
|
<tr>
|
||||||
|
<td>Accept Proxy Protocol</td>
|
||||||
|
<td>
|
||||||
|
<a-form-item>
|
||||||
|
<a-switch v-model="inbound.stream.sockopt.acceptProxyProtocol"></a-switch>
|
||||||
|
</a-form-item>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>TCP FastOpen</td>
|
||||||
|
<td>
|
||||||
|
<a-form-item>
|
||||||
|
<a-switch v-model.trim="inbound.stream.sockopt.tcpFastOpen"></a-switch>
|
||||||
|
</a-form-item>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Route Mark</td>
|
||||||
|
<td>
|
||||||
|
<a-form-item>
|
||||||
|
<a-input-number v-model="inbound.stream.sockopt.mark" :min="0"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>T-Proxy</td>
|
||||||
|
<td>
|
||||||
|
<a-form-item>
|
||||||
|
<a-select v-model="inbound.stream.sockopt.tproxy" style="width: 250px;"
|
||||||
|
:dropdown-class-name="themeSwitcher.darkCardClass">
|
||||||
|
<a-select-option value="off">OFF</a-select-option>
|
||||||
|
<a-select-option value="redirect">Redirect</a-select-option>
|
||||||
|
<a-select-option value="tproxy">T-Proxy</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</a-form>
|
||||||
|
{{end}}
|
Loading…
Reference in New Issue
Block a user