mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 05:13:38 +00:00
1. Fixed Control Channel bug, where host field never contained port number
2. Updated tunnels, so host field only contains port if its not a default port
This commit is contained in:
@@ -3374,7 +3374,16 @@ void MeshServer_ConnectEx(MeshAgentHostContainer *agent)
|
||||
req = ILibCreateEmptyPacket();
|
||||
ILibSetVersion(req, "1.1", 3);
|
||||
ILibSetDirective(req, "GET", 3, path, (int)strnlen_s(path, serverUrlLen));
|
||||
if ((port == 443 && strncmp("wss:", agent->serveruri, 4) == 0) || (port == 80 && strncmp("ws:", agent->serveruri, 3) == 0))
|
||||
{
|
||||
// Default Port, so host field only contains hostname
|
||||
ILibAddHeaderLine(req, "Host", 4, host, (int)strnlen_s(host, serverUrlLen));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Non default port, so host field needs to contain port number too
|
||||
ILibAddHeaderLine(req, "Host", 4, ILibScratchPad, (int)sprintf_s(ILibScratchPad, sizeof(ILibScratchPad), "%s:%u", host, port));
|
||||
}
|
||||
|
||||
free(path);
|
||||
|
||||
|
||||
@@ -1168,7 +1168,17 @@ duk_ret_t ILibDuktape_HttpStream_http_request(duk_context *ctx)
|
||||
duk_swap_top(ctx, -2); // [options][headers][concat][this]
|
||||
duk_push_string(ctx, ":"); // [options][headers][concat][this][:]
|
||||
duk_get_prop_string(ctx, -5, "port"); // [options][headers][concat][this][:][port]
|
||||
if ((strcmp("443", (char*)duk_to_string(ctx, -1)) == 0 && isTLS == 1) || (strcmp("80", (char*)duk_to_string(ctx, -1)) == 0 && isTLS == 0))
|
||||
{
|
||||
// No need to add port to host [options][headers][concat][this][:][port]
|
||||
duk_pop_2(ctx); // [options][headers][concat][this]
|
||||
duk_remove(ctx, -2); // [options][headers][host]
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add port to host
|
||||
duk_call_method(ctx, 2); // [options][headers][hostname]
|
||||
}
|
||||
duk_put_prop_string(ctx, -2, "Host"); // [options][headers]
|
||||
duk_put_prop_string(ctx, -2, "headers"); // [options]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user