X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FCommands%2Flxc.pm;h=e6ebb6cd47c69a249848dd0fb89f7c5b8bafd48f;hp=7403143e9f2d581ea5e59197a917dd433cd4649f;hb=6bb43016652af4ab78d34420ff0c8a5c5b0c9758;hpb=06039c7f9bb20ba7259cdf5dbc4f6fff5fd05efc diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm index 7403143..e6ebb6c 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" @@ -147,7 +148,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - my $conn = PVE::APIClient::Config->new()->remote_conn($param->{remote}); + my $config = PVE::APIClient::Config->load(); + my $conn = PVE::APIClient::Config->remote_conn($config, $param->{remote}); # Get the real node from the resources endpoint my $resource_list = $conn->get("api2/json/cluster/resources", { type => 'vm'}); @@ -172,7 +174,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 +206,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));