]> git.ipfire.org Git - people/stevee/guardian.git/blobdiff - modules/Events.pm
Only perform IP address related operations if an address has been passed.
[people/stevee/guardian.git] / modules / Events.pm
index fa3be24dabe7d58f0f202267dcbbf669696ecd57..cfc785ffc24ba00f430a4345558f79560b83fdd7 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 
 use Exporter qw(import);
 
-our @EXPORT_OK = qw(Init CheckAction Update);
+our @EXPORT_OK = qw(Init CheckAction GenerateIgnoreList Update);
 
 # Hash which stores all supported commands from the queue.
 my %commands = (
@@ -87,20 +87,23 @@ sub CheckAction ($$) {
                 return;
         }
 
-       # Convert and validate the given address.
-       my $bin_address = &Guardian::Base::IPOrNet2Int($address);
+       # Check if the given event contains an address.
+       if ($address) {
+               # Convert and validate the given address.
+               my $bin_address = &Guardian::Base::IPOrNet2Int($address);
 
-       # Abort if the given address could not be converted because it is not valid.
-       unless ($bin_address) {
-               $logger->Log("err", "Invalid IP address: $address");
-               return;
-       }
+               # Abort if the given address could not be converted because it is not valid.
+               unless ($bin_address) {
+                       $logger->Log("err", "Invalid IP address: $address");
+                       return;
+               }
 
-       # Check if address should be ignored.
-       if(&_IsOnIgnoreList($bin_address)) {
-               # Log message.
-               $logger->Log("info", "Ignoring event for $address, because it is part of the ignore list.");
-               return;
+               # Check if address should be ignored.
+               if(&_IsOnIgnoreList($bin_address)) {
+                       # Log message.
+                       $logger->Log("info", "Ignoring event for $address, because it is part of the ignore list.");
+                       return;
+               }
        }
 
        # Call required handler.
@@ -339,7 +342,8 @@ sub GenerateIgnoreList($) {
 #
 ## Private function to check if an address is part of the Ignore Hash.
 #
-## This function requires 
+## This function checks if a passed IP address in binary format (!),
+## directly or as part of an ignored network is stored in the ignore hash.
 #
 sub _IsOnIgnoreList ($) {
        my $bin_address = shift;