Net-Whois-IANA
view release on metacpan or search on metacpan
0.44 2018-07-13 17:32:55-06:00 America/Denver
- Adjust duplicate copyrights
- Adjust flapping test for BR country
- Try to improve testsuite stability using travis
- improve IPv4 regex
- improve cidr regex rule
- whois_connect avoid the last sleep
0.43 2018-07-13 14:26:35-06:00 America/Denver
- Skip results that are missing inetnum and inet6num
- fix duplicate country from apnic_read_query
- fix unit tests 'whois.registro.br' stop providing country
- accessors are defined at compile time and AUTOLOAD is not used
anymore
- Skip data for 0.0.0.0 that is returned from APNIC
- Net::Whois::IANA should not import dependency symbols
- Refactor whois_connect and source_connect to avoid memory crash loop
- Add IPv6 Support to Net::Whois::IANA
- Ripe queries should include all whois data
- Fix spaces in descr field
lib/Net/Whois/IANA.pm view on Meta::CPAN
lacnic => [ [ 'whois.lacnic.net', $WHOIS_PORT, $WHOIS_TIMEOUT, \&lacnic_query ], ],
afrinic => [ [ 'whois.afrinic.net', $WHOIS_PORT, $WHOIS_TIMEOUT, \&afrinic_query ],
],
);
@IANA = sort keys %IANA;
# accessors
# do not use AUTOLOAD - only accept lowercase function name
# define accessors at compile time
my @accessors = qw{country netname descr status source server inetnum inet6num cidr abuse fullinfo};
foreach my $accessor (@accessors) {
no strict 'refs';
*$accessor = sub {
my ($self) = @_;
die qq[$accessor is a method call] unless ref $self;
return unless $self->{QUERY};
return $self->{QUERY}->{$accessor};
};
}
lib/Net/Whois/IANA.pm view on Meta::CPAN
( defined $query{remarks} && $query{remarks} =~ /The country is really world wide/ )
|| ( defined $query{netname}
&& $query{netname} =~ /IANA-BLK/ )
|| ( defined $query{netname}
&& $query{netname} =~ /AFRINIC-NET-TRANSFERRED/ )
|| ( defined $query{country}
&& $query{country} =~ /world wide/ )
) {
return ();
}
elsif ( !$query{inet6num} && !$query{inetnum} ) {
return ();
}
else {
$query{permission} = 'allowed';
$query{cidr} = [ Net::CIDR::range2cidr( uc( $query{inet6num} || $query{inetnum} ) ) ];
}
return %query;
}
sub ripe_query ($$) {
my ( $sock, $ip ) = @_;
my %query = ripe_read_query( $sock, $ip );
return () unless defined $query{country};
return ripe_process_query(%query);
lib/Net/Whois/IANA.pm view on Meta::CPAN
next;
}
$skip_block = 0;
next;
}
next if $skip_block;
next if ( !/\:/ );
s/\s+$//;
my ( $field, $value ) = split( /:/, $_, 2 );
$value =~ s/^\s+//;
if ( $field =~ /^inet6?num$/ ) {
next if $value =~ m{0\.0\.0\.0\s+};
%tmp = %query;
%query = ();
$query{fullinfo} = $tmp{fullinfo};
}
my $lc_field = lc($field);
next if $lc_field eq 'country' && defined $query{$lc_field};
$query{$lc_field} .= ( $query{$lc_field} ? ' ' : '' ) . $value;
}
close $sock;
lib/Net/Whois/IANA.pm view on Meta::CPAN
sub apnic_process_query (%) {
my %query = @_;
if (
( defined $query{remarks} && $query{remarks} =~ /address range is not administered by APNIC|This network in not allocated/ )
|| ( defined $query{descr}
&& $query{descr} =~ /not allocated to|by APNIC|placeholder reference/i )
) {
return ();
}
elsif ( !$query{inet6num} && !$query{inetnum} ) {
return ();
}
else {
$query{permission} = 'allowed';
$query{cidr} = [ Net::CIDR::range2cidr( uc( $query{inet6num} || $query{inetnum} ) ) ];
}
return %query;
}
sub apnic_query ($$) {
my ( $sock, $ip ) = @_;
my %query = apnic_read_query( $sock, $ip );
return apnic_process_query(%query);
lib/Net/Whois/IANA.pm view on Meta::CPAN
*afrinic_read_query = *apnic_read_query;
sub afrinic_process_query (%) {
my %query = @_;
return ()
if defined $query{remarks} && $query{remarks} =~ /country is really worldwide/
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( uc( $query{inet6num} || $query{inetnum} ) ) ];
return %query;
}
sub afrinic_query ($$) {
my ( $sock, $ip ) = @_;
my %query = afrinic_read_query( $sock, $ip );
return afrinic_process_query(%query);
}
t/accessors.t view on Meta::CPAN
is( $iana->country(), 'NL', 'country' );
is( $iana->netname(), 'RIPE-NCC', 'netname' );
like( $iana->descr(), qr{RIPE Network}, "descr" );
is( $iana->desc(), $iana->descr(), "desc - backward compatible" );
is( $iana->status(), 'ASSIGNED PA', 'status' );
is( $iana->source(), 'RIPE RIPE', 'source' );
is( $iana->server(), 'RIPE', 'server' );
ok( $iana->inetnum(), 'inetnum' );
#is( $iana->inet6num(), 'NL', 'inet6num' );
( run in 0.270 second using v1.01-cache-2.11-cpan-5f2e87ce722 )