changeset 20:429b42047d04

Fix blocklist entry updating.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 15 Aug 2009 21:16:34 +0300
parents 4ad7550500a7
children 403cb1a110ce
files maltfilter
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/maltfilter	Sat Aug 15 21:07:47 2009 +0300
+++ b/maltfilter	Sat Aug 15 21:16:34 2009 +0300
@@ -446,9 +446,8 @@
 
 ### Get current Netfilter INPUT table entries that match
 ### entry types we manage, e.g. blocklist
-sub update_blocklist($)
+sub update_blocklist()
 {
-  my $mdate = $_[0];
   $ENV{"PATH"} = "";
   open(STATUS, $settings{"IPTABLES"}." -v -n -L INPUT |") or
     die("Could not execute ".$settings{"IPTABLES"}."\n");
@@ -458,10 +457,11 @@
     chomp;
     if (/^\s*(\d+)\s+\d+\s+$settings{"ACTION"}\s+all\s+--\s+\*\s+\*\s+(\d+\.\d+\.\d+\.\d+)\s+0\.0\.0\.0\/0\s*$/) {
       my $mip = $2;
-      if (!defined($blocklist{$mip}) && $mdate > 0) {
+      my $mdate = time();
+      if (!defined($blocklist{$mip})) {
         mlog(2, "* $mip appeared in iptables.\n");
+        $blocklist{$2} = $mdate;
       }
-      $blocklist{$2} = $mdate;
       update_entry(\%statlist, $mip, $mdate, "IPTABLES", "");
     }
   }
@@ -586,7 +586,7 @@
 ### Initialize
 sub malt_init {
   mlog(0, "Updating initial blocklist from netfilter.\n");
-  update_blocklist(-1);
+  update_blocklist();
 
   foreach my $filename (@scanfiles) {
     local *INFILE;
@@ -659,7 +659,7 @@
       # (in case entries have appeared there from "outside")
       # and perform weeding of old entries.
       $counter = 0;
-      update_blocklist(time());
+      update_blocklist();
       weed_entries();
       generate_status($settings{"STATUS_FILE_PLAIN"}, 0);
       generate_status($settings{"STATUS_FILE_HTML"}, 1);