From 644f6a870671ef1650d5a26b6b0f5ed6196dd246 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Fri, 14 Apr 2023 17:35:48 +0200 Subject: [PATCH] ipblocklist-functions.pl: Add function to get all enabled blocklists Signed-off-by: Stefan Schantl --- config/cfgroot/ipblocklist-functions.pl | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index a53018f11d..943d3fd345 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -69,6 +69,32 @@ sub get_blocklists () { return sort(@blocklists); } +# +## Function to get all enabled blocklists. +# +sub get_enabled_blocklists () { + my @enabled_blocklists; + my %settings; + + # Get all available blocklists. + my @blocklists = &get_blocklists(); + + # Read-in blocklist settings. + &General::readhash($settings_file, \%settings) if (-e $settings_file); + + # Loop through the array of available blocklists. + foreach my $blocklist (@blocklists) { + # Check if the blocklist is enabled. + if ((exists($settings{$blocklist})) && ($settings{$blocklist} eq "on")) { + # Add the blocklist to the array of enabled blocklists. + push(@enabled_blocklists, $blocklist); + } + } + + # Return the array of enabled blocklists. + return @enabled_blocklists; +} + # ## Function to get the full path and name of the cached blocklist. # -- 2.39.5