Commit c4d6e4bb authored by Dietmar Maurer's avatar Dietmar Maurer

spiceproxy: use tcp instead of unix socket

parent a1f1b60c
...@@ -480,7 +480,7 @@ sub handle_api2_request { ...@@ -480,7 +480,7 @@ sub handle_api2_request {
} }
sub handle_spice_proxy_request { sub handle_spice_proxy_request {
my ($self, $reqstate, $vmid, $node) = @_; my ($self, $reqstate, $vmid, $node, $spiceport) = @_;
eval { eval {
...@@ -500,16 +500,17 @@ sub handle_spice_proxy_request { ...@@ -500,16 +500,17 @@ sub handle_spice_proxy_request {
$reqstate->{hdl}->timeout(0); $reqstate->{hdl}->timeout(0);
# local node # local node
my $socket = PVE::QemuServer::spice_socket($vmid);
print "$$: CONNECT $vmid, $node, $socket\n" if $self->{debug}; print "$$: CONNECT $vmid, $node, $spiceport\n" if $self->{debug};
# fixme: use qmp add_client instead?
# fixme: this needs root privs # fixme: this needs root privs
tcp_connect "unix/", $socket, sub { tcp_connect "127.0.0.1", $spiceport, sub {
my ($fh) = @_ my ($fh) = @_
or die "connect to '$socket' failed: $!"; or die "connect to 'localhost:$spiceport' failed: $!";
print "$$: CONNECTed to $socket\n" if $self->{debug}; print "$$: CONNECTed to localhost:$spiceport\n" if $self->{debug};
$reqstate->{proxyhdl} = AnyEvent::Handle->new( $reqstate->{proxyhdl} = AnyEvent::Handle->new(
fh => $fh, fh => $fh,
rbuf_max => 64*1024, rbuf_max => 64*1024,
...@@ -851,12 +852,12 @@ sub unshift_read_header { ...@@ -851,12 +852,12 @@ sub unshift_read_header {
my $auth = {}; my $auth = {};
if ($self->{spiceproxy}) { if ($self->{spiceproxy}) {
my $connect_str = $r->header('Host'); my $connect_str = $r->header('Host');
my ($vmid, $node) = PVE::AccessControl::verify_spice_connect_url($connect_str); my ($vmid, $node, $port) = PVE::AccessControl::verify_spice_connect_url($connect_str);
if (!($vmid && $node)) { if (!($vmid && $node && $port)) {
$self->error($reqstate, HTTP_UNAUTHORIZED, "invalid ticket"); $self->error($reqstate, HTTP_UNAUTHORIZED, "invalid ticket");
return; return;
} }
$self->handle_spice_proxy_request($reqstate, $vmid, $node); $self->handle_spice_proxy_request($reqstate, $vmid, $node, $port);
return; return;
} elsif ($path =~ m!$baseuri!) { } elsif ($path =~ m!$baseuri!) {
my $token = $r->header('CSRFPreventionToken'); my $token = $r->header('CSRFPreventionToken');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment