people/stevee/guardian.git
2 years agoImprove Makefile.
Stefan Schantl [Mon, 27 Jun 2016 10:21:40 +0000 (12:21 +0200)]
Improve Makefile.

The Makefile now contains the version details which will
be substitued in the guardian.in and guardinctrl.in.

The Makefile now also supports commands for make clean and
to create a distribute-able tarball.

All installations path now can be adjusted by overwriting the
corresponding variables.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2 years agoRename main script from guardian to guardian.in.
Stefan Schantl [Mon, 27 Jun 2016 10:21:13 +0000 (12:21 +0200)]
Rename main script from guardian to guardian.in.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2 years agoAdd README file.
Stefan Schantl [Mon, 27 Jun 2016 10:19:16 +0000 (12:19 +0200)]
Add README file.

This file provides basic informations about guardian,
it's dependencies and how to build and install it.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2 years agoAdd example configuration file.
Stefan Schantl [Mon, 27 Jun 2016 10:17:36 +0000 (12:17 +0200)]
Add example configuration file.

This well documented example configuration file, provides
an overview about the features of guardian and can be used
for a customized configuration.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2 years agoIntroduce guardianctrl.
Stefan Schantl [Mon, 27 Jun 2016 10:12:26 +0000 (12:12 +0200)]
Introduce guardianctrl.

guardianctrl is a small perl written CLI client to interact with
a running guardian daemon.

It supports grabbing the current status of guardian, blocking and unblocking
of addresses, sending commands for releasing all currently blocks, reloading
the configuration, regenerating the ignore list and to tell the running daemon
that the monitored files have been rotated by logrotate.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoMerge remote-tracking branch 'logrotate'
Stefan Schantl [Tue, 14 Jun 2016 13:31:42 +0000 (15:31 +0200)]
Merge remote-tracking branch 'logrotate'

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoMerge branch 'parser-snort'
Stefan Schantl [Tue, 14 Jun 2016 13:28:14 +0000 (15:28 +0200)]
Merge branch 'parser-snort'

3 years agoAdd ability to reload the ignore list.
Stefan Schantl [Tue, 14 Jun 2016 11:28:16 +0000 (13:28 +0200)]
Add ability to reload the ignore list.

From now the ignore list easily can be reloaded by sending a
"SIGUSR1" signal to the guardian main process or by using the
UNIX socket and sending a "reload-ignore-list".

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAllow including additional ignore files.
Stefan Schantl [Tue, 14 Jun 2016 11:18:17 +0000 (13:18 +0200)]
Allow including additional ignore files.

This commit adds the ability to specify additinal files
in the include file which should be included. Any containing
IP-addresses of those files also will be added to the hash
of ignored IP-addresses.

To include a file, just add "Include_File = /file/to/be/included" to
the ignore file. There is no limitation for number of included files.

This feature can be used, to include system specific files which contains
IP-addresses which also should be added to the ignore list.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAllow to process multiple events at once.
Stefan Schantl [Mon, 29 Feb 2016 10:34:46 +0000 (11:34 +0100)]
Allow to process multiple events at once.

If a parser recives multiple lines at once, all of them
needs to be parsed and the result has to be returned to
the main process for enqueuing into the event queue.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAdd LogFacility for logging to a single file.
Stefan Schantl [Mon, 22 Feb 2016 10:58:26 +0000 (11:58 +0100)]
Add LogFacility for logging to a single file.

Introduce the LogFacility "file", which just sends and logs
all given log messages to a given file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoMerge branch 'parser-httpd'
Stefan Schantl [Fri, 19 Feb 2016 06:38:38 +0000 (07:38 +0100)]
Merge branch 'parser-httpd'

3 years agoAllow to configure the owner of the UNIX socket.
Stefan Schantl [Thu, 18 Feb 2016 14:04:22 +0000 (15:04 +0100)]
Allow to configure the owner of the UNIX socket.

Add option to configure an alternative owner of the created
UNIX socket, by using "SocketOwner = user:group" in the config
file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoIntroduce message parser for HTTPD related notifications.
Stefan Schantl [Thu, 18 Feb 2016 12:13:31 +0000 (13:13 +0100)]
Introduce message parser for HTTPD related notifications.

This new messge parser is able to detect htaccess related
brute-force login attempts on a running HTTPD server and
to report the source IP-address (IPv4 and IPv6).

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoMerge branch 'ssh-parser'
Stefan Schantl [Thu, 18 Feb 2016 09:52:46 +0000 (10:52 +0100)]
Merge branch 'ssh-parser'

3 years agoOnly process any actions on events if the corresponding parser returns one.
Stefan Schantl [Thu, 18 Feb 2016 09:48:11 +0000 (10:48 +0100)]
Only process any actions on events if the corresponding parser returns one.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoOnly try to re-read IgnoreFile on reload if one is configured.
Stefan Schantl [Thu, 18 Feb 2016 09:45:21 +0000 (10:45 +0100)]
Only try to re-read IgnoreFile on reload if one is configured.

Only try to read-in the IgnoreFile when calling an reload, if
one has been specified.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoIntroduce message parser for SSH related notifications.
Stefan Schantl [Thu, 18 Feb 2016 09:40:20 +0000 (10:40 +0100)]
Introduce message parser for SSH related notifications.

This new messge parser is able to detect SSH related
brute-force login attempts and to report the source
IP-address (IPv4 and IPv6).

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoRevert "Except and log if an event could not be parsed correctly."
Stefan Schantl [Thu, 18 Feb 2016 09:23:22 +0000 (10:23 +0100)]
Revert "Except and log if an event could not be parsed correctly."

This reverts commit dd0483736d6d2f194908eff73f36f50de1dd0197.

Breaks ability for skipping lines which are not,
affected by any filter (if-clause) of a parser.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoIntroduce message parser for snort alerts.
Stefan Schantl [Wed, 17 Feb 2016 13:29:42 +0000 (14:29 +0100)]
Introduce message parser for snort alerts.

This currently on IPv4 limited message parser is able to
parse and obtain various details from gained snort alerts.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAdd logrotate support.
Stefan Schantl [Wed, 17 Feb 2016 13:26:13 +0000 (14:26 +0100)]
Add logrotate support.

Add the ability to get informed when the monitored files
have been rotated by logrotate and therefore the stored
file positions needs to be re-newed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoRename &_initFileposition() to &GetFileposition() and allow to become exported.
Stefan Schantl [Wed, 17 Feb 2016 11:59:21 +0000 (12:59 +0100)]
Rename &_initFileposition() to &GetFileposition() and allow to become exported.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoExcept and log if an event could not be parsed correctly.
Stefan Schantl [Wed, 17 Feb 2016 11:52:58 +0000 (12:52 +0100)]
Except and log if an event could not be parsed correctly.

If the called parser is not able to parser the given message
for any event in the right way, except and log it as an error.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoDisplay number of elements in the ignore list.
Stefan Schantl [Thu, 4 Feb 2016 14:38:28 +0000 (15:38 +0100)]
Display number of elements in the ignore list.

When using "Debug" as log level now the number of elements which are
placed in the ignore list (%ignorehash) will be logged.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAlways whitelist localhost related addresses.
Stefan Schantl [Thu, 4 Feb 2016 08:18:44 +0000 (09:18 +0100)]
Always whitelist localhost related addresses.

This will prevent guardian from blocking the local
traffic.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAdd IPv6 support to IPtables module.
Stefan Schantl [Wed, 3 Feb 2016 13:53:13 +0000 (14:53 +0100)]
Add IPv6 support to IPtables module.

When using IPtables as firewall engine, now IPv6
addresses also can be handled in a proper way.

To do this, the correct iptables helper binary will be choosen,
based on the IP address which should be (un)blocked and executed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAdd reload handler to Events module.
Stefan Schantl [Wed, 3 Feb 2016 08:33:50 +0000 (09:33 +0100)]
Add reload handler to Events module.

This allows to call a Reload by sending the corresponding
command via socket.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoUpdate ignore list on reload.
Stefan Schantl [Wed, 3 Feb 2016 08:32:53 +0000 (09:32 +0100)]
Update ignore list on reload.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoOnly perform IP address related operations if an address has been passed.
Stefan Schantl [Wed, 3 Feb 2016 08:25:51 +0000 (09:25 +0100)]
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 <stefan.schantl@ipfire.org>
3 years agoAllow export of the GenerateIgnoreList() function.
Stefan Schantl [Wed, 3 Feb 2016 07:54:52 +0000 (08:54 +0100)]
Allow export of the GenerateIgnoreList() function.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoDrop obsolete IsValidAddressOrNetwork() function.
Stefan Schantl [Wed, 3 Feb 2016 07:41:24 +0000 (08:41 +0100)]
Drop obsolete IsValidAddressOrNetwork() function.

This function is not longer used, because during converting a given
address or network the input will be validated, so there is no need for
this function anymore.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAdd functionality for whitelisting single addresses or network ranges.
Stefan Schantl [Wed, 3 Feb 2016 07:34:12 +0000 (08:34 +0100)]
Add functionality for whitelisting single addresses or network ranges.

This commit adds the posibilty for generating a ignore list based on a
set of IP addresses or networks (IPv4/IPv6 are supported) which are provided
by an so called ignore file.

The path and the filename can be configured by using the "IgnoreFile = /path/to/somefile"
option inside the config file of guardian. Using this feature is completely optional and
only be activated if an ignore file has been specified.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoValidate IP addresses before passing to the firewall module.
Stefan Schantl [Tue, 26 Jan 2016 14:25:01 +0000 (15:25 +0100)]
Validate IP addresses before passing to the firewall module.

Use the external Net::IP perl module to do a proper IPv4/IPv6 address or
network validation.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoRename and move InitFileposition function.
Stefan Schantl [Fri, 22 Jan 2016 13:55:41 +0000 (14:55 +0100)]
Rename and move InitFileposition function.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAllow to configure the used parser for a monitored file.
Stefan Schantl [Fri, 22 Jan 2016 12:26:55 +0000 (13:26 +0100)]
Allow to configure the used parser for a monitored file.

This commit adds support to assign the used parser for a
configured monitored file. The information which parser
should be used directly will be obtained from the
configuration option.

For example "Monitor_Snort = /path/to/snort/alert/file" will
monitor the specified file as before, but will try to use
the parser called "snort" (parsers internal completely are handled
in lower case format) to parser any messages which are written to
that file.

This will remove the static filename <-> parser structure, which will
allow a better implementation of parsers or customized parsers in the
future and a better portability to other systems.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoAllow to configure the firewall action which will be performed.
Stefan Schantl [Tue, 19 Jan 2016 13:41:57 +0000 (14:41 +0100)]
Allow to configure the firewall action which will be performed.

This commit adds the posibility to configure which action will be
passed to the firewall engine when blocking an IP address.

To prevent from any missconfiguration, the requested action will be
validated by the responsible firewall engine module before it get
executed.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 years agoEnhance returned error messages from Event module.
Stefan Schantl [Tue, 19 Jan 2016 12:57:26 +0000 (13:57 +0100)]
Enhance returned error messages from Event module.

Add details about the used FirewallEngine, when recieving any error
message from the responsible engine module. This information will be
quite usefull, in error case and help to debug the main problem.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>