mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
ws earlydata compatible with xray
This commit is contained in:
@@ -8,11 +8,24 @@ namespace NekoRay::fmt {
|
||||
if (network != "tcp") {
|
||||
QJsonObject transport{{"type", network}};
|
||||
if (network == "ws") {
|
||||
if (!path.isEmpty()) transport["path"] = path;
|
||||
if (!host.isEmpty()) transport["headers"] = QJsonObject{{"Host", host}};
|
||||
// ws path & ed
|
||||
auto pathWithoutEd = SubStrBefore(path, "?ed=");
|
||||
if (!pathWithoutEd.isEmpty()) transport["path"] = pathWithoutEd;
|
||||
if (pathWithoutEd != path) {
|
||||
auto ed = SubStrAfter(path, "?ed=").toInt();
|
||||
if (ed > 0) {
|
||||
transport["max_early_data"] = ed;
|
||||
transport["early_data_header_name"] = "Sec-WebSocket-Protocol";
|
||||
}
|
||||
}
|
||||
if (ws_early_data_length > 0) {
|
||||
transport["max_early_data"] = ws_early_data_length;
|
||||
transport["early_data_header_name"] = ws_early_data_name;
|
||||
if (ws_early_data_name.isEmpty()) {
|
||||
transport["early_data_header_name"] = "Sec-WebSocket-Protocol";
|
||||
} else {
|
||||
transport["early_data_header_name"] = ws_early_data_name;
|
||||
}
|
||||
}
|
||||
} else if (network == "http") {
|
||||
if (!path.isEmpty()) transport["path"] = path;
|
||||
|
||||
@@ -13,11 +13,24 @@ namespace NekoRay::fmt {
|
||||
|
||||
if (network == "ws") {
|
||||
QJsonObject ws;
|
||||
if (!path.isEmpty()) ws["path"] = path;
|
||||
if (!host.isEmpty()) ws["headers"] = QJsonObject{{"Host", host}};
|
||||
// ws path & ed
|
||||
auto pathWithoutEd = SubStrBefore(path, "?ed=");
|
||||
if (!pathWithoutEd.isEmpty()) ws["path"] = pathWithoutEd;
|
||||
if (pathWithoutEd != path) {
|
||||
auto ed = SubStrAfter(path, "?ed=").toInt();
|
||||
if (ed > 0) {
|
||||
ws["maxEarlyData"] = ed;
|
||||
ws["earlyDataHeaderName"] = "Sec-WebSocket-Protocol";
|
||||
}
|
||||
}
|
||||
if (ws_early_data_length > 0) {
|
||||
ws["maxEarlyData"] = ws_early_data_length;
|
||||
ws["earlyDataHeaderName"] = ws_early_data_name;
|
||||
if (ws_early_data_name.isEmpty()) {
|
||||
ws["earlyDataHeaderName"] = "Sec-WebSocket-Protocol";
|
||||
} else {
|
||||
ws["earlyDataHeaderName"] = ws_early_data_name;
|
||||
}
|
||||
}
|
||||
streamSettings["wsSettings"] = ws;
|
||||
} else if (network == "http") {
|
||||
|
||||
Reference in New Issue
Block a user