]> git.proxmox.com Git - pmg-api.git/commitdiff
fix bug #1643: add port and protocol to spamquarantine config
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 31 Jan 2018 10:48:39 +0000 (11:48 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 31 Jan 2018 11:41:10 +0000 (12:41 +0100)
to change the links in the spamreport, this does not change
on which port/protocol the webinterface listens,
so we do not want to expose those options in the webinterface

also fix a typo in a description

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PMG/CLI/pmgqm.pm
PMG/Config.pm

index 75726299b088115c869b6c544b0ad244e8fe0f62..c9fd59f0583b49a81e5f8a072368050e0253f3d6 100755 (executable)
@@ -94,7 +94,7 @@ sub get_item_data {
     $item->{spaminfo} = $ref->{info};
     $item->{file} = $ref->{file};
 
-    my $basehref = "https://$data->{fqdn}:$data->{port}/quarantine";
+    my $basehref = "$data->{protocol}://$data->{fqdn}:$data->{port}/quarantine";
     my $ticket = uri_escape($data->{ticket});
     $item->{href} = "$basehref?ticket=$ticket&cselect=$item->{id}&date=$item->{date}";
 
@@ -242,10 +242,12 @@ __PACKAGE__->register_method ({
        my $fqdn = $cfg->get('spamquar', 'hostname') //
            PVE::Tools::get_fqdn($hostname);
 
-       my $port = 8006;
+       my $port = $cfg->get('spamquar', 'port') // 8006;
+
+       my $protocol = $cfg->get('spamquar', 'protocol') // 'https';
 
        my $global_data = {
-           protocol => 'https',
+           protocol => $protocol,
            port => $port,
            fqdn => $fqdn,
            hostname => $hostname,
@@ -323,7 +325,7 @@ __PACKAGE__->register_method ({
                $data->{pmail} = $creceiver;
                $data->{ticket} = PMG::Ticket::assemble_quarantine_ticket($data->{pmail});
                my $esc_ticket = uri_escape($data->{ticket});
-               $data->{managehref} = "https://$fqdn:$port/quarantine?ticket=${esc_ticket}";
+               $data->{managehref} = "$protocol://$fqdn:$port/quarantine?ticket=${esc_ticket}";
            }
 
            push @{$data->{items}}, get_item_data($data, $ref);
index 956963997a87449683756e8b4c4bcb4da85797bd..6832d75911c884a95b57b0b3ab6488ee839170aa 100755 (executable)
@@ -228,9 +228,22 @@ sub properties {
            default => 1,
        },
        hostname => {
-           description => "Quarantine Host. Usefule if you run a Cluster and want users to connect to a specific host.",
+           description => "Quarantine Host. Useful if you run a Cluster and want users to connect to a specific host.",
            type => 'string', format => 'address',
        },
+       port => {
+           description => "Quarantine Port. Useful if you have a reverse proxy or port forwarding for the webinterface. Only used for the generated Spam report.",
+           type => 'integer',
+           minimum => 1,
+           maximum => 65535,
+           default => 8006,
+       },
+       protocol => {
+           description => "Quarantine Webinterface Protocol. Useful if you have a reverse proxy for the webinterface. Only used for the generated Spam report.",
+           type => 'string',
+           enum => [qw(http https)],
+           default => 'https',
+       },
        mailfrom => {
            description => "Text for 'From' header in daily spam report mails.",
            type => 'string',
@@ -247,6 +260,8 @@ sub options {
        reportstyle => { optional => 1 },
        viewimages => { optional => 1 },
        allowhrefs => { optional => 1 },
+       port => { optional => 1 },
+       protocol => { optional => 1 },
     };
 }