new - splithttp transport

splithttp inbound
splithttp outbound
change priority host for ws - httpupgrade (host>>headers)
This commit is contained in:
mhsanaei
2024-06-18 12:49:20 +02:00
parent 52b02fdef9
commit 7f2c11220f
8 changed files with 268 additions and 169 deletions

View File

@@ -194,7 +194,7 @@ class WsStreamSettings extends CommonClass {
static fromJson(json={}) {
return new WsStreamSettings(
json.path,
json.host
json.host,
);
}
@@ -202,7 +202,6 @@ class WsStreamSettings extends CommonClass {
return {
path: this.path,
host: this.host,
headers: ObjectUtil.isEmpty(this.host) ? undefined : {Host: this.host},
};
}
}
@@ -288,7 +287,29 @@ class HttpUpgradeStreamSettings extends CommonClass {
static fromJson(json={}) {
return new HttpUpgradeStreamSettings(
json.path,
json.host
json.host,
);
}
toJson() {
return {
path: this.path,
host: this.host,
};
}
}
class SplitHTTPStreamSettings extends CommonClass {
constructor(path='/', host='') {
super();
this.path = path;
this.host = host;
}
static fromJson(json={}) {
return new SplitHTTPStreamSettings(
json.path,
json.host,
);
}
@@ -296,7 +317,6 @@ class HttpUpgradeStreamSettings extends CommonClass {
return {
path: this.path,
host: this.host,
headers: ObjectUtil.isEmpty(this.host) ? undefined : {Host: this.host},
};
}
}
@@ -404,6 +424,7 @@ class StreamSettings extends CommonClass {
quicSettings=new QuicStreamSettings(),
grpcSettings=new GrpcStreamSettings(),
httpupgradeSettings=new HttpUpgradeStreamSettings(),
splithttpSettings=new SplitHTTPStreamSettings(),
sockopt = undefined,
) {
super();
@@ -418,6 +439,7 @@ class StreamSettings extends CommonClass {
this.quic = quicSettings;
this.grpc = grpcSettings;
this.httpupgrade = httpupgradeSettings;
this.splithttp = splithttpSettings;
this.sockopt = sockopt;
}
@@ -450,6 +472,7 @@ class StreamSettings extends CommonClass {
QuicStreamSettings.fromJson(json.quicSettings),
GrpcStreamSettings.fromJson(json.grpcSettings),
HttpUpgradeStreamSettings.fromJson(json.httpupgradeSettings),
SplitHTTPStreamSettings.fromJson(json.splithttpSettings),
SockoptStreamSettings.fromJson(json.sockopt),
);
}
@@ -468,6 +491,7 @@ class StreamSettings extends CommonClass {
quicSettings: network === 'quic' ? this.quic.toJson() : undefined,
grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined,
httpupgradeSettings: network === 'httpupgrade' ? this.httpupgrade.toJson() : undefined,
splithttpSettings: network === 'splithttp' ? this.splithttp.toJson() : undefined,
sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined,
};
}
@@ -532,7 +556,7 @@ class Outbound extends CommonClass {
canEnableTls() {
if (![Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(this.protocol)) return false;
return ["tcp", "ws", "http", "quic", "grpc", "httpupgrade"].includes(this.stream.network);
return ["tcp", "ws", "http", "quic", "grpc", "httpupgrade" , "splithttp"].includes(this.stream.network);
}
//this is used for xtls-rprx-vision
@@ -653,6 +677,8 @@ class Outbound extends CommonClass {
stream.grpc = new GrpcStreamSettings(json.path, json.authority, json.type == 'multi');
} else if (network === 'httpupgrade') {
stream.httpupgrade = new HttpUpgradeStreamSettings(json.path,json.host);
} else if (network === 'splithttp') {
stream.splithttp = new SplitHTTPStreamSettings(json.path,json.host);
}
if(json.tls && json.tls == 'tls'){
@@ -700,6 +726,8 @@ class Outbound extends CommonClass {
url.searchParams.get('mode') == 'multi');
} else if (type === 'httpupgrade') {
stream.httpupgrade = new HttpUpgradeStreamSettings(path,host);
} else if (type === 'splithttp') {
stream.splithttp = new SplitHTTPStreamSettings(path,host);
}
if(security == 'tls'){