Subject: | "Bad starting address" warning when using whois_query on IP |
When using an IP not in the IANA range this is raising a warning whereas we should prefer returning an empty list
perl -MNet::Whois::IANA -E 'Net::Whois::IANA->new()->whois_query( -ip => q[190.56.253.22] )'
Bad starting address
at /usr/local/perl/perls/perl-5.26.1/lib/site_perl/5.26.1/Net/Whois/IANA.pm line 537.
Attached is a suggested fix, which can also be view on GitHub at https://github.com/atoomic/Net-Whois-IANA/pull/1
Subject: | 0001-Skip-results-that-are-missing-inetnum-and-inet6num.patch |
From bdabad13b887dc7b06792a53549ed1910d9968b2 Mon Sep 17 00:00:00 2001
From: Nicolas R <atoomic@cpan.org>
Date: Thu, 12 Jul 2018 09:38:30 -0600
Subject: [PATCH] Skip results that are missing inetnum and inet6num
The result parser would try to send everything though
Net::CIDR even if there was not result. Skip results
that are missing this data to avoid an exception so
the system can move on to the next whois server.
Author: "J. Nick Koston" <nick@cpanel.net>
---
lib/Net/Whois/IANA.pm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/Net/Whois/IANA.pm b/lib/Net/Whois/IANA.pm
index 57cdccb..d555807 100644
--- a/lib/Net/Whois/IANA.pm
+++ b/lib/Net/Whois/IANA.pm
@@ -294,6 +294,9 @@ sub ripe_process_query (%) {
) {
return ();
}
+ elsif ( !$query{inet6num} && !$query{inetnum} ) {
+ return ();
+ }
else {
$query{permission} = 'allowed';
$query{cidr} = [ Net::CIDR::range2cidr($query{inetnum}) ];
@@ -354,6 +357,9 @@ sub apnic_process_query (%) {
) {
return ();
}
+ elsif ( !$query{inet6num} && !$query{inetnum} ) {
+ return ();
+ }
else {
$query{permission} = 'allowed';
$query{cidr} = [Net::CIDR::range2cidr($query{inetnum})];
@@ -533,6 +539,11 @@ sub afrinic_process_query (%) {
or
defined $query{descr} &&
$query{descr} =~ /Here for in-addr\.arpa authentication/;
+
+ if ( !$query{inet6num} && !$query{inetnum} ) {
+ return ();
+ }
+
$query{permission} = 'allowed';
$query{cidr} = [ Net::CIDR::range2cidr($query{inetnum}) ];
return %query;
--
2.15.2 (Apple Git-101.1)