# HG changeset patch # User Matti Hamalainen # Date 1250360194 -10800 # Node ID 429b42047d0496ecd577995e45fe70c00209e695 # Parent 4ad7550500a712730922ff26def28ea5503a5c55 Fix blocklist entry updating. diff -r 4ad7550500a7 -r 429b42047d04 maltfilter --- 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);