mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
ipblocklist-functions.pl: Add parser to obtain IP or Net addresses from
a blocklist. Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
committed by
Stefan Schantl
parent
ba8455e469
commit
ab0179617d
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user