]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Use Events module to perform various actions.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 19 Jan 2016 11:51:05 +0000 (12:51 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 19 Jan 2016 11:51:05 +0000 (12:51 +0100)
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>
guardian

index 2a5b460da4d37137e43211570007da01d28b155d..07e0c146c74d7c31ae2292d21dafcd19c9c2ddc6 100644 (file)
--- a/guardian
+++ b/guardian
@@ -30,6 +30,7 @@ use Time::HiRes qw[ time sleep ];
 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;
@@ -86,6 +87,9 @@ $mainsettings{Logger} = $logger;
 # 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 = ();
@@ -124,10 +128,18 @@ while(1) {
                # 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);
 }