From 48af7914781fc038347cec95e2ca76db720bd3b8 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 16 Apr 2023 16:14:38 +0200 Subject: [PATCH] firewall-lib.pl: Introduce get_custom_groups() function. This function is used to get a list of all created custom host/nework groups. Signed-off-by: Stefan Schantl --- config/firewall/firewall-lib.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/config/firewall/firewall-lib.pl b/config/firewall/firewall-lib.pl index 7d35d5686..767a9675d 100644 --- a/config/firewall/firewall-lib.pl +++ b/config/firewall/firewall-lib.pl @@ -640,4 +640,27 @@ sub location_is_available($) { return; } +sub get_custom_groups () { + # Array to store all found host/networks groups. + my @groups = (); + + # Loop through the hash of customgroups. + foreach my $key (keys %customgrp) { + # Omit the group name. + my $group_name = $customgrp{$key}[0]; + + # Add the group to the groups array. + push(@groups, $group_name); + } + + # Remove any double entries. + @groups = &General::uniq(@groups); + + # Sort the group names in alphabetical order. + @groups = sort(@groups); + + # Return the array. + return @groups; +} + return 1; -- 2.39.5