From: Stefan Schantl Date: Wed, 3 Feb 2016 08:25:51 +0000 (+0100) Subject: Only perform IP address related operations if an address has been passed. X-Git-Tag: 2.0~37 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=e1ff25ceca1c0e00af6881ba737aeadaa93c51d9 Only perform IP address related operations if an address has been passed. Some events does not contain any IP address informations, therefore there is no need to call any address related operations. Signed-off-by: Stefan Schantl --- diff --git a/modules/Events.pm b/modules/Events.pm index 8f04f3d..cfc785f 100644 --- a/modules/Events.pm +++ b/modules/Events.pm @@ -87,20 +87,23 @@ sub CheckAction ($$) { return; } - # 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; - } + # 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; + } - # 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.