From: Tim FitzGeorge Date: Fri, 4 Mar 2022 21:08:16 +0000 (+0100) Subject: ipblocklist-functions.pl: Add parser to obtain IP or Net addresses from X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7ac9ef0db96bc0ff786dc006189dc657ea2d2d9;p=people%2Fstevee%2Fipfire-2.x.git ipblocklist-functions.pl: Add parser to obtain IP or Net addresses from a blocklist. Signed-off-by: Tim FitzGeorge Signed-off-by: Stefan Schantl --- diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index f312e349a6..9e862bb0ec 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -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;