]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
firewall-lib.pl: Introduce get_custom_groups() function.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 16 Apr 2023 14:14:38 +0000 (16:14 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 16 Apr 2023 14:14:38 +0000 (16:14 +0200)
This function is used to get a list of all created custom
host/nework groups.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/firewall/firewall-lib.pl

index 7d35d5686453c253ac8875627bf0a74c06a3f185..767a9675de5f6eef0c92d529de3212461025f10a 100644 (file)
@@ -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;