From: Stefan Schantl Date: Wed, 13 Jul 2016 12:21:46 +0000 (+0200) Subject: Update event handler settings on reload. X-Git-Tag: 2.0~7 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=1044256085fc81fbc64475688bb1d0a347f4b123 Update event handler settings on reload. The values for BlockCount and BlockTime now will be updated when performing a reload. Signed-off-by: Stefan Schantl --- diff --git a/guardian.in b/guardian.in index bbf4eb5..c52b832 100644 --- a/guardian.in +++ b/guardian.in @@ -395,6 +395,9 @@ sub Reload () { # Update logger object in mainsettings hash. $mainsettings{Logger} = $logger; + # Update Event handler. + $events->Update(\%mainsettings); + # Update ignore list. &ReloadIgnoreList(); diff --git a/modules/Events.pm b/modules/Events.pm index f8437de..ec253c0 100644 --- a/modules/Events.pm +++ b/modules/Events.pm @@ -80,6 +80,34 @@ sub Init (%) { return $self; } +# +## The "Update" Block settings function. +# +## This object based function is called to update various class settings. +# +sub Update (\%) { + my $self = shift; + + # Dereference the given hash-ref and store + # the values into a new temporary hash. + my %settings = %{ $_[0] }; + + # Skip settings update if some essential settings are missing. + unless ((exists($settings{BlockCount})) && (exists($settings{BlockTime}))) { + $logger->Log("err", "Values for BlockCount or BlockTime are missing, keeping previously configured settings."); + + # Return unmodified class object. + return $self; + } + + # Change settings. + $self->{BlockCount} = $settings{BlockCount}; + $self->{BlockTime} = $settings{BlockTime}; + + # Return modified class object. + return $self; +} + # ## The main "CheckAction" function. #