mirror of
https://github.com/AMS-IX/arpsponge.git
synced 2024-09-21 07:47:08 +00:00
Fix is_valid_ip()
to only accept literal IPv4 addresses
`NetAddr::IP` will call `gethostbyname` if the argument is not a literal IP address, and hence try to do DNS resolving on it. Cute, but not relevant here, and not fully functional, since a host name with a `-` in it would have been split as a range in `asctl`.
This commit is contained in:
parent
ef1bf30e86
commit
675fdb9711
@ -466,10 +466,11 @@ sub is_valid_bool {
|
||||
|
||||
###############################################################################
|
||||
|
||||
=item X<is_valid_ip>B<is_valid_ip> ( I<ARG>
|
||||
=item B<is_valid_ip> ( I<ARG>
|
||||
[, B<-network> =E<gt> I<CIDR>]
|
||||
[, B<-err> =E<gt> I<REF>]
|
||||
)
|
||||
X<is_valid_ip>
|
||||
|
||||
Check whether I<ARG> is defined and represents a valid IPv4 address.
|
||||
If I<CIDR> is given, it also checks whether the address is part
|
||||
@ -491,7 +492,7 @@ sub is_valid_ip {
|
||||
return;
|
||||
}
|
||||
|
||||
my $ip = NetAddr::IP->new($arg);
|
||||
my $ip = $arg =~ /^\d/ ? NetAddr::IP->new($arg) : undef;
|
||||
if (!$ip) {
|
||||
${$opts{-err}} = qq/"$arg" is not a valid IPv4 address/;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user