]> git.ipfire.org Git - people/stevee/guardian.git/log
people/stevee/guardian.git
8 years agoAdjust Parser and Socket module outputs.
Stefan Schantl [Tue, 19 Jan 2016 11:55:20 +0000 (12:55 +0100)] 
Adjust Parser and Socket module outputs.

Adjusting the module outputs to proper work again and
to provide the required information for the Event module.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoSet default FirewallEngine to "none".
Stefan Schantl [Tue, 19 Jan 2016 11:54:02 +0000 (12:54 +0100)] 
Set default FirewallEngine to "none".

This will prevent guardian from running if no firewall engine has been
specified in the config file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoUse Events module to perform various actions.
Stefan Schantl [Tue, 19 Jan 2016 11:51:05 +0000 (12:51 +0100)] 
Use Events module to perform various actions.

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>
8 years agoIntroduce "IPtables" module.
Stefan Schantl [Tue, 19 Jan 2016 11:43:28 +0000 (12:43 +0100)] 
Introduce "IPtables" module.

This module is used to allow any interaction of guardian with
an IPtables based firewall backed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoIntroduce "Events" module
Stefan Schantl [Tue, 19 Jan 2016 11:32:32 +0000 (12:32 +0100)] 
Introduce "Events" module

This module is responsible for reading the the events which will be enqued by
the various parsers and perform various actions, based on the type of the event.

The default action is to count all events for a given IP address and if the configured
"BlockCount" has been reached to call the configured "FirewallEngine" to perform a
block for this address.

The Events module also will be used, to perform any event which will be sent through the
Socket.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoValidate configured LogLevel when reading-in the config file.
Stefan Schantl [Mon, 18 Jan 2016 12:50:43 +0000 (13:50 +0100)] 
Validate configured LogLevel when reading-in the config file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoPrevent from running guardian twice.
Stefan Schantl [Wed, 9 Dec 2015 13:49:11 +0000 (14:49 +0100)] 
Prevent from running guardian twice.

Guardian now checks for an already running instance on startup and will
cancel if there has been found one.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoDrop PID file when exiting guardian.
Stefan Schantl [Wed, 9 Dec 2015 13:48:35 +0000 (14:48 +0100)] 
Drop PID file when exiting guardian.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd support to daemonize guardian.
Stefan Schantl [Wed, 9 Dec 2015 13:46:17 +0000 (14:46 +0100)] 
Add support to daemonize guardian.

Guardian now will be launched in daemon mode as default. Using the
"--foreground (-f)" command line switch will prevent the process from
forking into the background.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd "Daemon" module.
Stefan Schantl [Wed, 9 Dec 2015 13:43:36 +0000 (14:43 +0100)] 
Add "Daemon" module.

This module contains various functions which can be used to Daemonize (forking guardian into background), writing PID (process-id) files and to determine if an instance of guardian is already running.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoRename "New" method to "Init" for creating or updating the Logger.
Stefan Schantl [Wed, 9 Dec 2015 12:29:20 +0000 (13:29 +0100)] 
Rename "New" method to "Init" for creating or updating the Logger.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoRemove Update method from Logger module.
Stefan Schantl [Wed, 9 Dec 2015 10:06:46 +0000 (11:06 +0100)] 
Remove Update method from Logger module.

If any settings has been changed, just recall the "New" method
again and pass the new settings.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoRemove any whitespaces from configlines.
Stefan Schantl [Sun, 6 Dec 2015 10:27:29 +0000 (11:27 +0100)] 
Remove any whitespaces from configlines.

Previously only whitespaces from the begin and end
of a config line has been dropped which cause
troubles if a line contains them between the config
option and the value. (LogLevel = debug)

Now simply all whitespaces will be dropped which solved
those problems.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoPass logger object to the mainsettings hash for a usage
Stefan Schantl [Sun, 6 Dec 2015 09:38:46 +0000 (10:38 +0100)] 
Pass logger object to the mainsettings hash for a usage
inside of the modules.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdjust error messages in case of failure.
Stefan Schantl [Wed, 25 Nov 2015 14:38:01 +0000 (15:38 +0100)] 
Adjust error messages in case of failure.

Remove the new line prefixes from various error messages.
The logger automatically will take care of this.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoRedirect the "die" messages to the logger.
Stefan Schantl [Wed, 25 Nov 2015 14:29:04 +0000 (15:29 +0100)] 
Redirect the "die" messages to the logger.

When an error occurs and perl dies, the provided error messages now
will be handled/logged by the "Logger" module.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoUse "Logger" module for logging purposes.
Stefan Schantl [Wed, 25 Nov 2015 14:27:07 +0000 (15:27 +0100)] 
Use "Logger" module for logging purposes.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoDo not display warnings for threads anymore.
Stefan Schantl [Wed, 25 Nov 2015 13:26:28 +0000 (14:26 +0100)] 
Do not display warnings for threads anymore.

This commit disables warnings about unjoind or running threads when
shutdown guardian.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoJust send "KILL" signal to the worker threads.
Stefan Schantl [Wed, 25 Nov 2015 11:22:49 +0000 (12:22 +0100)] 
Just send "KILL" signal to the worker threads.

Only send the "KILL" signal to the worker threads, do not detach
the process anymore. Otherwise guardian will fail after a second reload
because a detached thread cannot be detached a second time.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd support to reload the service.
Stefan Schantl [Wed, 25 Nov 2015 11:21:34 +0000 (12:21 +0100)] 
Add support to reload the service.

When sending a "SIGHUP" signal to the guardian process,
we now doing a complete reload of the configuration.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoDecelerate shutdown process for one second.
Stefan Schantl [Wed, 25 Nov 2015 08:24:54 +0000 (09:24 +0100)] 
Decelerate shutdown process for one second.

When shutting down guardian the function now will pause for
one second to give perl some more time to proper clean up
everything before finally exiting the process.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd license information.
Stefan Schantl [Wed, 25 Nov 2015 08:20:38 +0000 (09:20 +0100)] 
Add license information.

guardian is licensed under the terms of the GPLv3.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoRework handling of monitored files.
Stefan Schantl [Wed, 25 Nov 2015 08:07:55 +0000 (09:07 +0100)] 
Rework handling of monitored files.

From now a hash is used to store which files should be monitored
and to store their current cursor position. The entire hash is shared
between the main process and the worker threads.

A benefit of this is, to keep the current cursor position of each monitored file
during thread restarts and the hash is also designed to be re-generated in case of
a service reload without loosing any relevant data.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoDrop function for fileposition initialization.
Stefan Schantl [Wed, 25 Nov 2015 08:06:46 +0000 (09:06 +0100)] 
Drop function for fileposition initialization.

This function has been moved to the "Base" module.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoIntroduce "Base" module
Stefan Schantl [Wed, 25 Nov 2015 08:04:55 +0000 (09:04 +0100)] 
Introduce "Base" module

This module just contains some basic functions of guardian.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAllow to dynamically start/stop worker threads.
Stefan Schantl [Tue, 24 Nov 2015 13:09:09 +0000 (14:09 +0100)] 
Allow to dynamically start/stop worker threads.

All worker threads now dynamically can be started or stopped by calling the
responsible functions (StartWorkers, StopWorkers).

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoEnable and use the warnings core module.
Stefan Schantl [Tue, 24 Nov 2015 12:26:34 +0000 (13:26 +0100)] 
Enable and use the warnings core module.

When using the warnings module, perl will display a lot
of usefull informations when launching the script and
therefore helps to improve the code.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoUse TimeHires core module for main loop interupting.
Stefan Schantl [Tue, 24 Nov 2015 12:20:41 +0000 (13:20 +0100)] 
Use TimeHires core module for main loop interupting.

Using the TimeHires module and interupting the main loop for
10 miliseconds will reduce the cpu load of guardian to almost
zero instead of burning it.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoCapture process signals.
Stefan Schantl [Mon, 23 Nov 2015 09:34:55 +0000 (10:34 +0100)] 
Capture process signals.

guardian now captures sent process siganls and can perform
various actions based on the captured signal. Currently only
"INT", "TERM", and "QUIT" signals are handeled. Some other
may be added in the future.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoSocket.pm: Add tiny subroutine to drop an existing socket file.
Stefan Schantl [Mon, 23 Nov 2015 09:31:52 +0000 (10:31 +0100)] 
Socket.pm: Add tiny subroutine to drop an existing socket file.

This function can be called at any time to release the socket file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoSocket.pm: Fix error messages when crashing.
Stefan Schantl [Mon, 23 Nov 2015 09:24:52 +0000 (10:24 +0100)] 
Socket.pm: Fix error messages when crashing.

When the module crashed (died) for some reasons, the provided details where
empty.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoSocket.pm: Fix detection and deletion of an existing socket file.
Stefan Schantl [Mon, 23 Nov 2015 09:23:55 +0000 (10:23 +0100)] 
Socket.pm: Fix detection and deletion of an existing socket file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd support for command line arguments and usage of "Config" module.
Stefan Schantl [Mon, 23 Nov 2015 08:57:25 +0000 (09:57 +0100)] 
Add support for command line arguments and usage of "Config" module.

guardian now can be called with some additional command line arguments, like
"--config" to specify a different config file than the default one. The optoions
"--help" and "--vesion" will display some help texts and version informations on
the console. The "--foreground" option is not supported/implemented yet and will
be used to keep the process in the foreground and not fork into background at a later
time.

The "Config" module now also is used to get all settings from the config file and
store them into a hash called mainsettings for a later usage.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoUse socket module to provide an IPC mechanism.
Stefan Schantl [Fri, 20 Nov 2015 21:56:02 +0000 (22:56 +0100)] 
Use socket module to provide an IPC mechanism.

Guardian now supports inter-process-communication based on
an UNIX socket, which is based on the guardians socket module.

All recieved messages via socket automatically will be accepted
and parsed. If they are valid, the corresponding events will be
enqueued into the main event queue of guardian.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd "Socket" module.
Stefan Schantl [Fri, 20 Nov 2015 21:37:29 +0000 (22:37 +0100)] 
Add "Socket" module.

The Socket module provides an IPC mechanism for guardian, based
on a UNIX socket. It contains a server, a client and a message parser
function which easily can be re-used.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd "Config" module.
Stefan Schantl [Fri, 20 Nov 2015 20:56:49 +0000 (21:56 +0100)] 
Add "Config" module.

This module contains functions to read, validate and set various
configure options which are used in guardian.

The main functions called "UseConfig" allows to pass which config file
should be read and validates the input by calling a subfunction. The
validated settings will be returend as a hash.

The "CheckConfig" function directly can be called with a hash, which
contains the various config options and values and will return an
error message if there are any problems.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoAdd "Logger" module.
Stefan Schantl [Fri, 20 Nov 2015 14:23:56 +0000 (15:23 +0100)] 
Add "Logger" module.

This module is responsible for logging any messages which are generated by
guaridan or one of its submodules during runtime and displays them on the
console or send them to the syslog.

When using the logger module, it has to be initialized as an object, which calls the
"New" function and requires the following settings:

* LogLevel - which has to be "off, err, info or debug"
* LogFacility - which currently supports "console or syslog"

After that, logging can be done, by using the "Log" function on the object, by providing
the type of the message (LogLevel) and the message self.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
8 years agoInitial checkin.
Stefan Schantl [Thu, 12 Nov 2015 22:07:44 +0000 (23:07 +0100)] 
Initial checkin.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>