]> git.proxmox.com Git - pve-http-server.git/blobdiff - PVE/APIServer/AnyEvent.pm
allow 'download' to be passed from API handler
[pve-http-server.git] / PVE / APIServer / AnyEvent.pm
index d3b48b74f6810d69ff5d7c8f597605d9c8ac3324..60a2a1c5f64628acd0cb1ea6beadc07cc565de18 100644 (file)
@@ -812,7 +812,10 @@ sub handle_api2_request {
            $delay = 0 if $delay < 0;
        }
 
-       if (defined(my $download = $res->{download})) {
+       my $download = $res->{download};
+       $download //= $res->{data}->{download}
+            if defined($res->{data}) && ref($res->{data}) eq 'HASH';
+       if (defined($download)) {
            send_file_start($self, $reqstate, $download);
            return;
        }
@@ -1544,6 +1547,7 @@ sub check_host_access {
        foreach my $t (@{$self->{allow_from}}) {
            if ($t->overlaps($cip)) {
                $match_allow = 1;
+               $self->dprint("client IP allowed: ". $t->prefix());
                last;
            }
        }
@@ -1552,6 +1556,7 @@ sub check_host_access {
     if ($self->{deny_from}) {
        foreach my $t (@{$self->{deny_from}}) {
            if ($t->overlaps($cip)) {
+               $self->dprint("client IP denied: ". $t->prefix());
                $match_deny = 1;
                last;
            }
@@ -1585,6 +1590,7 @@ sub accept_connections {
                my ($pfamily, $pport, $phost) = PVE::Tools::unpack_sockaddr_in46($sin);
                ($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport,  Socket::inet_ntop($pfamily, $phost));
            } else {
+               $self->dprint("getpeername failed: $!");
                close($clientfh);
                next;
            }
@@ -1634,6 +1640,7 @@ sub accept_connections {
 
     if (my $err = $@) {
        syslog('err', $err);
+       $self->dprint("connection accept error: $err");
        close($clientfh);
        if ($handle_creation) {
            if ($self->{conn_count} <= 0) {