diff --git a/fmt/Bean2CoreObj_box.cpp b/fmt/Bean2CoreObj_box.cpp index d92e6ee..27a64ce 100644 --- a/fmt/Bean2CoreObj_box.cpp +++ b/fmt/Bean2CoreObj_box.cpp @@ -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; diff --git a/fmt/Bean2CoreObj_ray.cpp b/fmt/Bean2CoreObj_ray.cpp index e03c928..c971154 100644 --- a/fmt/Bean2CoreObj_ray.cpp +++ b/fmt/Bean2CoreObj_ray.cpp @@ -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") {