From: Dominik Csapak Date: Wed, 31 Jan 2018 10:48:39 +0000 (+0100) Subject: fix bug #1643: add port and protocol to spamquarantine config X-Git-Url: https://git.proxmox.com/?p=pmg-api.git;a=commitdiff_plain;h=c333c6e01ab2a034ebbbf21dbe964d8fedcbdaca fix bug #1643: add port and protocol to spamquarantine config 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 --- diff --git a/PMG/CLI/pmgqm.pm b/PMG/CLI/pmgqm.pm index 7572629..c9fd59f 100755 --- a/PMG/CLI/pmgqm.pm +++ b/PMG/CLI/pmgqm.pm @@ -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); diff --git a/PMG/Config.pm b/PMG/Config.pm index 9569639..6832d75 100755 --- a/PMG/Config.pm +++ b/PMG/Config.pm @@ -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 }, }; }