Guardian now uses the Events module to perform various actions, based
on the recieved event by a parser or the socket.
Periodly guardian is calling the "RemoveBlocks" function from the
Events module to release the block of an IP address if the configured
BlockTime has been passed.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
require Guardian::Base;
require Guardian::Config;
require Guardian::Daemon;
require Guardian::Base;
require Guardian::Config;
require Guardian::Daemon;
+require Guardian::Events;
require Guardian::Logger;
require Guardian::Parser;
require Guardian::Socket;
require Guardian::Logger;
require Guardian::Parser;
require Guardian::Socket;
# Redirect perls "die" messages to the logger before exiting.
$SIG{__DIE__} = sub { $logger->Log("err", "@_"); };
# Redirect perls "die" messages to the logger before exiting.
$SIG{__DIE__} = sub { $logger->Log("err", "@_"); };
+# Initialize the event handler.
+my $events = Guardian::Events->Init(%mainsettings);
+
# Shared hash between the main process and all threads. It will store all
# monitored files and their current file position.
my %monitored_files :shared = ();
# Shared hash between the main process and all threads. It will store all
# monitored files and their current file position.
my %monitored_files :shared = ();
# Log processed event.
$logger->Log("debug", "QUEUE - Processed event: $event");
# Log processed event.
$logger->Log("debug", "QUEUE - Processed event: $event");
+ # Send event data to the events parser to determine
+ # if any action is required.
+ $events->CheckAction($event);
+
# Drop processed event from queue.
$queue->dequeue();
}
# Drop processed event from queue.
$queue->dequeue();
}
+ # Call RemoveBlocks routine from the Events module to check
+ # if items from the block list can be dropped.
+ $events->RemoveBlocks();
+
# Sleep 10ms to reduce the load of the main process.
sleep(0.01);
}
# Sleep 10ms to reduce the load of the main process.
sleep(0.01);
}