SplitHTTP - Mode

Co-Authored-By: MHSanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Alireza Ahmadi
2024-11-16 15:41:42 +01:00
parent 31cec0280a
commit 2f61bbcfdd
6 changed files with 56 additions and 8 deletions

View File

@@ -230,6 +230,7 @@ func (s *SubService) genVmessLink(inbound *model.Inbound, email string) string {
headers, _ := splithttp["headers"].(map[string]interface{}) headers, _ := splithttp["headers"].(map[string]interface{})
obj["host"] = searchHost(headers) obj["host"] = searchHost(headers)
} }
obj["mode"] = splithttp["mode"].(string)
} }
security, _ := stream["security"].(string) security, _ := stream["security"].(string)
@@ -381,6 +382,7 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string {
headers, _ := splithttp["headers"].(map[string]interface{}) headers, _ := splithttp["headers"].(map[string]interface{})
params["host"] = searchHost(headers) params["host"] = searchHost(headers)
} }
params["mode"] = splithttp["mode"].(string)
} }
security, _ := stream["security"].(string) security, _ := stream["security"].(string)
if security == "tls" { if security == "tls" {
@@ -578,6 +580,7 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string
headers, _ := splithttp["headers"].(map[string]interface{}) headers, _ := splithttp["headers"].(map[string]interface{})
params["host"] = searchHost(headers) params["host"] = searchHost(headers)
} }
params["mode"] = splithttp["mode"].(string)
} }
security, _ := stream["security"].(string) security, _ := stream["security"].(string)
if security == "tls" { if security == "tls" {
@@ -771,6 +774,7 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st
headers, _ := splithttp["headers"].(map[string]interface{}) headers, _ := splithttp["headers"].(map[string]interface{})
params["host"] = searchHost(headers) params["host"] = searchHost(headers)
} }
params["mode"] = splithttp["mode"].(string)
} }
security, _ := stream["security"].(string) security, _ := stream["security"].(string)

View File

@@ -69,12 +69,19 @@ const WireguardDomainStrategy = [
"ForceIPv6v4" "ForceIPv6v4"
]; ];
const MODE_OPTION = {
AUTO: "auto",
PACKET_UP: "packet-up",
STREAM_UP: "stream-up",
};
Object.freeze(Protocols); Object.freeze(Protocols);
Object.freeze(SSMethods); Object.freeze(SSMethods);
Object.freeze(TLS_FLOW_CONTROL); Object.freeze(TLS_FLOW_CONTROL);
Object.freeze(ALPN_OPTION); Object.freeze(ALPN_OPTION);
Object.freeze(OutboundDomainStrategies); Object.freeze(OutboundDomainStrategies);
Object.freeze(WireguardDomainStrategy); Object.freeze(WireguardDomainStrategy);
Object.freeze(MODE_OPTION);
class CommonClass { class CommonClass {
@@ -272,16 +279,18 @@ class HttpUpgradeStreamSettings extends CommonClass {
} }
class SplitHTTPStreamSettings extends CommonClass { class SplitHTTPStreamSettings extends CommonClass {
constructor(path='/', host='') { constructor(path='/', host='',mode = '') {
super(); super();
this.path = path; this.path = path;
this.host = host; this.host = host;
this.mode = mode;
} }
static fromJson(json={}) { static fromJson(json={}) {
return new SplitHTTPStreamSettings( return new SplitHTTPStreamSettings(
json.path, json.path,
json.host, json.host,
json.mode,
); );
} }
@@ -289,6 +298,7 @@ class SplitHTTPStreamSettings extends CommonClass {
return { return {
path: this.path, path: this.path,
host: this.host, host: this.host,
mode: this.mode,
}; };
} }
} }
@@ -643,7 +653,7 @@ class Outbound extends CommonClass {
} else if (network === 'httpupgrade') { } else if (network === 'httpupgrade') {
stream.httpupgrade = new HttpUpgradeStreamSettings(json.path,json.host); stream.httpupgrade = new HttpUpgradeStreamSettings(json.path,json.host);
} else if (network === 'splithttp') { } else if (network === 'splithttp') {
stream.splithttp = new SplitHTTPStreamSettings(json.path,json.host); stream.splithttp = new SplitHTTPStreamSettings(json.path,json.host,json.mode);
} }
if(json.tls && json.tls == 'tls'){ if(json.tls && json.tls == 'tls'){
@@ -687,7 +697,7 @@ class Outbound extends CommonClass {
} else if (type === 'httpupgrade') { } else if (type === 'httpupgrade') {
stream.httpupgrade = new HttpUpgradeStreamSettings(path,host); stream.httpupgrade = new HttpUpgradeStreamSettings(path,host);
} else if (type === 'splithttp') { } else if (type === 'splithttp') {
stream.splithttp = new SplitHTTPStreamSettings(path,host); stream.splithttp = new SplitHTTPStreamSettings(path,host,mode);
} }
if(security == 'tls'){ if(security == 'tls'){

View File

@@ -79,6 +79,12 @@ const SNIFFING_OPTION = {
FAKEDNS: "fakedns" FAKEDNS: "fakedns"
}; };
const MODE_OPTION = {
AUTO: "auto",
PACKET_UP: "packet-up",
STREAM_UP: "stream-up",
};
Object.freeze(Protocols); Object.freeze(Protocols);
Object.freeze(SSMethods); Object.freeze(SSMethods);
Object.freeze(TLS_FLOW_CONTROL); Object.freeze(TLS_FLOW_CONTROL);
@@ -87,6 +93,8 @@ Object.freeze(TLS_CIPHER_OPTION);
Object.freeze(UTLS_FINGERPRINT); Object.freeze(UTLS_FINGERPRINT);
Object.freeze(ALPN_OPTION); Object.freeze(ALPN_OPTION);
Object.freeze(SNIFFING_OPTION); Object.freeze(SNIFFING_OPTION);
Object.freeze(MODE_OPTION);
class XrayCommonClass { class XrayCommonClass {
@@ -463,7 +471,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
maxConnections: 0, maxConnections: 0,
cMaxReuseTimes: "64-128", cMaxReuseTimes: "64-128",
cMaxLifetimeMs: 0 cMaxLifetimeMs: 0
} },
mode = MODE_OPTION.AUTO,
) { ) {
super(); super();
this.path = path; this.path = path;
@@ -474,7 +483,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
this.scMinPostsIntervalMs = scMinPostsIntervalMs; this.scMinPostsIntervalMs = scMinPostsIntervalMs;
this.noSSEHeader = noSSEHeader; this.noSSEHeader = noSSEHeader;
this.xPaddingBytes = xPaddingBytes; this.xPaddingBytes = xPaddingBytes;
this.xmux = xmux; this.xmux = xmux;
this.mode = mode;
} }
addHeader(name, value) { addHeader(name, value) {
@@ -496,6 +506,7 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
json.noSSEHeader, json.noSSEHeader,
json.xPaddingBytes, json.xPaddingBytes,
json.xmux, json.xmux,
json.mode,
); );
} }
@@ -514,7 +525,8 @@ class SplitHTTPStreamSettings extends XrayCommonClass {
maxConnections: this.xmux.maxConnections, maxConnections: this.xmux.maxConnections,
cMaxReuseTimes: this.xmux.cMaxReuseTimes, cMaxReuseTimes: this.xmux.cMaxReuseTimes,
cMaxLifetimeMs: this.xmux.cMaxLifetimeMs cMaxLifetimeMs: this.xmux.cMaxLifetimeMs
} },
mode: this.mode,
}; };
} }
} }
@@ -1065,7 +1077,7 @@ class Inbound extends XrayCommonClass {
canEnableReality() { canEnableReality() {
if(![Protocols.VLESS, Protocols.TROJAN].includes(this.protocol)) return false; if(![Protocols.VLESS, Protocols.TROJAN].includes(this.protocol)) return false;
return ["tcp", "http", "grpc"].includes(this.network); return ["tcp", "http", "grpc", "splithttp"].includes(this.network);
} }
canEnableStream() { canEnableStream() {
@@ -1133,6 +1145,7 @@ class Inbound extends XrayCommonClass {
const splithttp = this.stream.splithttp; const splithttp = this.stream.splithttp;
obj.path = splithttp.path; obj.path = splithttp.path;
obj.host = splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host'); obj.host = splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host');
obj.mode = splithttp.mode;
} }
if (security === 'tls') { if (security === 'tls') {
@@ -1205,6 +1218,7 @@ class Inbound extends XrayCommonClass {
const splithttp = this.stream.splithttp; const splithttp = this.stream.splithttp;
params.set("path", splithttp.path); params.set("path", splithttp.path);
params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host')); params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host'));
params.set("mode", splithttp.mode);
break; break;
} }
@@ -1308,6 +1322,7 @@ class Inbound extends XrayCommonClass {
const splithttp = this.stream.splithttp; const splithttp = this.stream.splithttp;
params.set("path", splithttp.path); params.set("path", splithttp.path);
params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host')); params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host'));
params.set("mode", splithttp.mode);
break; break;
} }
@@ -1390,6 +1405,7 @@ class Inbound extends XrayCommonClass {
const splithttp = this.stream.splithttp; const splithttp = this.stream.splithttp;
params.set("path", splithttp.path); params.set("path", splithttp.path);
params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host')); params.set("host", splithttp.host?.length>0 ? splithttp.host : this.getHeader(splithttp, 'host'));
params.set("mode", splithttp.mode);
break; break;
} }

View File

@@ -371,6 +371,11 @@
<a-form-item label='{{ i18n "path" }}'> <a-form-item label='{{ i18n "path" }}'>
<a-input v-model.trim="outbound.stream.splithttp.path"></a-input> <a-input v-model.trim="outbound.stream.splithttp.path"></a-input>
</a-form-item> </a-form-item>
<a-form-item label='Mode'>
<a-select v-model="outbound.stream.splithttp.mode" :dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="key in MODE_OPTION" :value="key">[[ key ]]</a-select-option>
</a-select>
</a-form-item>
</template> </template>
</template> </template>

View File

@@ -22,6 +22,12 @@
</a-input> </a-input>
</a-input-group> </a-input-group>
</a-form-item> </a-form-item>
<a-form-item label='Mode'>
<a-select v-model="inbound.stream.splithttp.mode" style="width: 50%"
:dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="key in MODE_OPTION" :value="key">[[ key ]]</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="Max Concurrent Upload"> <a-form-item label="Max Concurrent Upload">
<a-input v-model.trim="inbound.stream.splithttp.scMaxConcurrentPosts"></a-input> <a-input v-model.trim="inbound.stream.splithttp.scMaxConcurrentPosts"></a-input>
</a-form-item> </a-form-item>

View File

@@ -44,7 +44,14 @@
<td v-else><a-tag color="orange">{{ i18n "none" }}</a-tag></td> <td v-else><a-tag color="orange">{{ i18n "none" }}</a-tag></td>
</tr> </tr>
</template> </template>
<template v-if="inbound.isSplithttp">
<tr>
<td>Mode</td>
<td>
<a-tag>[[ inbound.stream.splithttp.mode ]]</a-tag>
</td>
</tr>
</template>
<template v-if="inbound.isKcp"> <template v-if="inbound.isKcp">
<tr><td>kcp {{ i18n "encryption" }}</td><td><a-tag>[[ inbound.kcpType ]]</a-tag></td></tr> <tr><td>kcp {{ i18n "encryption" }}</td><td><a-tag>[[ inbound.kcpType ]]</a-tag></td></tr>
<tr><td>kcp {{ i18n "password" }}</td><td><a-tag>[[ inbound.kcpSeed ]]</a-tag></td></tr> <tr><td>kcp {{ i18n "password" }}</td><td><a-tag>[[ inbound.kcpSeed ]]</a-tag></td></tr>