]> git.proxmox.com Git - pmg-api.git/blobdiff - PMG/Config.pm
fix bug #1646: domains - allow to use wildcard domains
[pmg-api.git] / PMG / Config.pm
index 8b1c2dcfe15e8940352a448f466b0f2ec775e10e..18b076aefd0e9c258db86315863a66f56bae4462 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 },
     };
 }
 
@@ -1013,17 +1028,27 @@ sub get_template_vars {
     my $mynetworks = [ '127.0.0.0/8', '[::1]/128' ];
 
     if (my $int_net_cidr = PMG::Utils::find_local_network_for_ip($int_ip, 1)) {
-       push @$mynetworks, $int_net_cidr;
+       if ($int_net_cidr =~ m/^($IPV6RE)\/(\d+)$/) {
+           push @$mynetworks, "[$1]/$2";
+       } else {
+           push @$mynetworks, $int_net_cidr;
+       }
     } else {
        if ($int_ip =~ m/^$IPV6RE$/) {
-           push @$mynetworks, "$int_ip/128";
+           push @$mynetworks, "[$int_ip]/128";
        } else {
            push @$mynetworks, "$int_ip/32";
        }
     }
 
     my $netlist = PVE::INotify::read_file('mynetworks');
-    push @$mynetworks, keys %$netlist;
+    foreach my $cidr (keys %$netlist) {
+       if ($cidr =~ m/^($IPV6RE)\/(\d+)$/) {
+           push @$mynetworks, "[$1]/$2";
+       } else {
+           push @$mynetworks, $cidr;
+       }
+    }
 
     push @$mynetworks, @$transportnets;
 
@@ -1051,6 +1076,12 @@ sub get_template_vars {
        $self->get('mail', 'spf');
     $vars->{postfix}->{usepolicy} = $usepolicy;
 
+    if ($int_ip =~ m/^$IPV6RE$/) {
+        $vars->{postfix}->{int_ip} = "[$int_ip]";
+    } else {
+        $vars->{postfix}->{int_ip} = $int_ip;
+    }
+
     my $resolv = PVE::INotify::read_file('resolvconf');
     $vars->{dns}->{hostname} = $nodename;