ws earlydata compatible with xray

This commit is contained in:
arm64v8a
2023-05-06 17:43:03 +09:00
parent 51616b5a9a
commit f53d0aba47
2 changed files with 30 additions and 4 deletions

View File

@@ -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") {