X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FCommands%2Flxc.pm;h=e6ebb6cd47c69a249848dd0fb89f7c5b8bafd48f;hp=8a5cfb4813be0e966cba27c99e8a7e75ec70d33e;hb=6bb43016652af4ab78d34420ff0c8a5c5b0c9758;hpb=84d4c3e267b85215f825c903d8beed3068612246 diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm index 8a5cfb4..e6ebb6c 100644 --- a/PVE/APIClient/Commands/lxc.pm +++ b/PVE/APIClient/Commands/lxc.pm @@ -8,6 +8,7 @@ use IO::Select; use IO::Socket::SSL; use MIME::Base64; use Digest::SHA; +use HTTP::Response; use PVE::Tools; use PVE::JSONSchema qw(get_standard_option); @@ -20,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; @@ -35,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" @@ -146,7 +148,8 @@ __PACKAGE__->register_method ({ code => sub { my ($param) = @_; - my $conn = PVE::APIClient::Config::get_remote_connection($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'}); @@ -171,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); @@ -203,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));