]> git.ipfire.org Git - people/stevee/guardian.git/blobdiff - modules/Events.pm
Drop address from counthash when manually unblocking a host.
[people/stevee/guardian.git] / modules / Events.pm
index f8437deedbf594d13dd1a34d4367b2dd23e33d61..30fdd968ee5acacd3fe5ab4f40e0423d89b5d6a2 100644 (file)
@@ -80,6 +80,34 @@ sub Init (%) {
        return $self;
 }
 
+#
+## The "Update" Block settings function.
+#
+## This object based function is called to update various class settings.
+#
+sub Update (\%) {
+        my $self = shift;
+
+       # Dereference the given hash-ref and store
+       # the values into a new temporary hash.
+       my %settings = %{ $_[0] };
+
+       # Skip settings update if some essential settings are missing.
+       unless ((exists($settings{BlockCount})) && (exists($settings{BlockTime}))) {
+               $logger->Log("err", "Values for BlockCount or BlockTime are missing, keeping previously configured settings.");
+
+               # Return unmodified class object.
+               return $self;
+       }
+
+       # Change settings.
+        $self->{BlockCount} = $settings{BlockCount};
+       $self->{BlockTime} = $settings{BlockTime};
+
+       # Return modified class object.
+        return $self;
+}
+
 #
 ## The main "CheckAction" function.
 #
@@ -292,6 +320,12 @@ sub CallUnblock ($) {
        # Drop address from blockhash.
        delete ($blockhash{$address});
 
+       # Drop address from counthash if the address has been unblocked
+       # by the user. This happens when the called module is "Socket".
+       if ($module eq "Socket") {
+               delete ($counthash{$address});
+       }
+
        # Everything worked well, return nothing.
        return undef;
 }