Skip to content

Commit

Permalink
Use Data::Validate::IP in scanhost.pl, too
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaran committed Mar 11, 2020
1 parent 99086d2 commit 5745060
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions bin/scanhost.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Net::CIDR::Set;
use Getopt::Long qw(GetOptions);
use Pod::Usage qw(pod2usage);
use Data::Validate::IP qw(is_ip);

our $VERSION = '0.1';

Expand Down Expand Up @@ -83,19 +84,7 @@

sub lookup {
my ($address, $sock) = @_;
if ($address =~ m(
# IPv4, not necessarily valid, would match 321.456.789.257
^ ( \d{1,3} \. ){1,3} \d{1,3} $ |
# IPv6 without "::"
^ ( [a-f0-9]{1,4} : ){7} [a-f0-9]{1,4} $ |
# IPv6 with "::" in the last place
^ ( [a-f0-9]{1,4} : ){1,7} : [a-f0-9]{1,4} $ | # Abbreviated IPv6
# IPv6 with "::" somewhere inbetween, possibly too long address
^ ( [a-f0-9]{1,4} : ){1,6} : ( [a-f0-9]{1,4} : ){1,6} [a-f0-9]{1,4} $ |
# IPv6 with "::" in the first place, like fe80::…
^ [a-f0-9]{1,4} :: ( [a-f0-9]{1,4} : ){1,6} [a-f0-9]{1,4} $
)xi) {

if (is_ip($address)) {
my $reply = $res->query($address, 'PTR');
if ($reply) {
foreach my $rr ($reply->answer) {
Expand Down

0 comments on commit 5745060

Please sign in to comment.