[pmg-devel] [PATCH pmg-api 1/1] add port and protocol to spamquarantine config
Dominik Csapak
d.csapak at proxmox.com
Wed Jan 31 11:48:39 CET 2018
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 at proxmox.com>
---
PMG/CLI/pmgqm.pm | 10 ++++++----
PMG/Config.pm | 17 ++++++++++++++++-
2 files changed, 22 insertions(+), 5 deletions(-)
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 },
};
}
--
2.11.0
More information about the pmg-devel
mailing list