mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
ws earlydata compatible with xray
This commit is contained in:
@@ -8,11 +8,24 @@ namespace NekoRay::fmt {
|
|||||||
if (network != "tcp") {
|
if (network != "tcp") {
|
||||||
QJsonObject transport{{"type", network}};
|
QJsonObject transport{{"type", network}};
|
||||||
if (network == "ws") {
|
if (network == "ws") {
|
||||||
if (!path.isEmpty()) transport["path"] = path;
|
|
||||||
if (!host.isEmpty()) transport["headers"] = QJsonObject{{"Host", host}};
|
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) {
|
if (ws_early_data_length > 0) {
|
||||||
transport["max_early_data"] = ws_early_data_length;
|
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") {
|
} else if (network == "http") {
|
||||||
if (!path.isEmpty()) transport["path"] = path;
|
if (!path.isEmpty()) transport["path"] = path;
|
||||||
|
|||||||
@@ -13,11 +13,24 @@ namespace NekoRay::fmt {
|
|||||||
|
|
||||||
if (network == "ws") {
|
if (network == "ws") {
|
||||||
QJsonObject ws;
|
QJsonObject ws;
|
||||||
if (!path.isEmpty()) ws["path"] = path;
|
|
||||||
if (!host.isEmpty()) ws["headers"] = QJsonObject{{"Host", host}};
|
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) {
|
if (ws_early_data_length > 0) {
|
||||||
ws["maxEarlyData"] = ws_early_data_length;
|
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;
|
streamSettings["wsSettings"] = ws;
|
||||||
} else if (network == "http") {
|
} else if (network == "http") {
|
||||||
|
|||||||
Reference in New Issue
Block a user