]> git.proxmox.com Git - pve-firewall.git/commitdiff
ipset: only save ip/network once
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 7 Apr 2014 09:02:14 +0000 (11:02 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 7 Apr 2014 09:02:14 +0000 (11:02 +0200)
We do not allow duplicate entries.

src/PVE/Firewall.pm

index 74bd8d962eaad4868b0bcaaa9449c568e58a1f63..5168093d9fca75ff0cd42d9d46865ff984449fa7 100644 (file)
@@ -2143,7 +2143,13 @@ my $format_ipset = sub {
 
     my $raw = '';
 
 
     my $raw = '';
 
+    my $nethash = {};
     foreach my $entry (@$options) {
     foreach my $entry (@$options) {
+       $nethash->{$entry->{cidr}} = $entry;
+    }
+
+    foreach my $cidr (sort keys %$nethash) {
+       my $entry = $nethash->{$cidr};
        my $line = $entry->{nomatch} ? '!' : '';
        $line .= $entry->{cidr};
        $line .= " # " . encode('utf8', $entry->{comment})
        my $line = $entry->{nomatch} ? '!' : '';
        $line .= $entry->{cidr};
        $line .= " # " . encode('utf8', $entry->{comment})