From e1ff25ceca1c0e00af6881ba737aeadaa93c51d9 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 3 Feb 2016 09:25:51 +0100 Subject: [PATCH] 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 --- modules/Events.pm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) 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. -- 2.39.2