[pve-devel] applied: [PATCH pve-client v2 1/2] Fix the WebSocket client to work with none PVE servers.
Dietmar Maurer
dietmar at proxmox.com
Wed Jun 6 07:57:32 CEST 2018
applied
> On June 5, 2018 at 6:03 PM René Jochum <r.jochum at proxmox.com> wrote:
>
>
> For debugging I tested the WebSocket client with my Protocol::WebSocket
> server (i have hexdumps in it), this patch is required to make it work
> with it. I'm pretty sure we need it for Proxies too.
> ---
> PVE/APIClient/Commands/lxc.pm | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
> index 7403143..8cd41ff 100644
> --- a/PVE/APIClient/Commands/lxc.pm
> +++ b/PVE/APIClient/Commands/lxc.pm
> @@ -21,7 +21,7 @@ my $CRLF = "\x0D\x0A";
> my $max_payload_size = 65536;
>
> my $build_web_socket_request = sub {
> - my ($path, $ticket, $termproxy) = @_;
> + my ($host, $path, $ticket, $termproxy) = @_;
>
> my $key = '';
> $key .= chr(int(rand(256))) for 1 .. 16;
> @@ -36,6 +36,7 @@ my $build_web_socket_request = sub {
> my $request = "GET $path HTTP/1.1$CRLF"
> . "Upgrade: WebSocket$CRLF"
> . "Connection: Upgrade$CRLF"
> + . "Host: $host$CRLF"
> . "Sec-WebSocket-Key: $enckey$CRLF"
> . "Sec-WebSocket-Version: 13$CRLF"
> . "Sec-WebSocket-Protocol: binary$CRLF"
> @@ -172,7 +173,7 @@ __PACKAGE__->register_method ({
> # WebSocket Handshake
>
> my ($request, $wskey) = $build_web_socket_request->(
> - "/$api_path/vncwebsocket", $conn->{ticket}, $termproxy);
> + $conn->{host}, "/$api_path/vncwebsocket", $conn->{ticket}, $termproxy);
>
> $web_socket->syswrite($request);
>
> @@ -204,8 +205,8 @@ __PACKAGE__->register_method ({
>
> die "got invalid websocket reponse: $raw_response\n"
> if !(($response->code == 101) &&
> - ($response->header('connection') eq 'upgrade') &&
> - ($response->header('upgrade') eq 'websocket') &&
> + (lc $response->header('connection') eq 'upgrade') &&
> + (lc $response->header('upgrade') eq 'websocket') &&
> ($response->header('sec-websocket-protocol') eq 'binary') &&
> ($response->header('sec-websocket-accept') eq $wsaccept));
>
> --
> 2.11.0
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list