]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ipblocklist-functions.pl: Add parser to obtain IP or Net addresses from
authorTim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Fri, 4 Mar 2022 21:08:16 +0000 (22:08 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 7 Jul 2022 15:26:13 +0000 (17:26 +0200)
a blocklist.

Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/ipblocklist-functions.pl

index f312e349a6f07764bc2be06d616f869014637f97..9e862bb0ec67176a7f0d277b4f28cde945cf0ced 100644 (file)
@@ -257,4 +257,25 @@ sub download_and_create_blocklist($) {
        return;
 }
 
+#
+## sub parse_ip_or_net_list( line )
+##
+## Parses an input line, looking for lines starting with an IP Address or
+### Network specification.
+##
+## Parameters:
+##   line  The line to parse
+##
+## Returns:
+##   Either an IP Address or a null string
+#
+sub parse_ip_or_net_list( $ ) {
+       my ($line) = @_;
+
+       # Grab the IP address or network.
+       $line =~ m|^(\d+\.\d+\.\d+\.\d+(?:/\d+)?)|;
+
+       # Return the grabbed address.
+       return $1;
+}
 1;