From: Stefan Schantl Date: Sun, 16 Apr 2023 14:14:38 +0000 (+0200) Subject: firewall-lib.pl: Introduce get_custom_groups() function. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48af7914781fc038347cec95e2ca76db720bd3b8;p=people%2Fstevee%2Fipfire-2.x.git 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 --- 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;