| 1 | package Net::Whois::ARIN; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | Net::Whois::ARIN - ARIN whois client | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | use Net::Whois::ARIN; | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | my $w = Net::Whois::ARIN->new( | ||||||||||||||||||||||||||||||||
| 12 | host => 'whois.arin.net', | ||||||||||||||||||||||||||||||||
| 13 | port => 43, | ||||||||||||||||||||||||||||||||
| 14 | timeout => 30, | ||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | # fetch raw whois output as a scalar | ||||||||||||||||||||||||||||||||
| 18 | my $result = $w->query( '207.173.0.0' ); | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | # fetch raw whois output as a list | ||||||||||||||||||||||||||||||||
| 21 | my @results = $w->query( 'NET-207-173-0-0-1' ); | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | # search for a network record | ||||||||||||||||||||||||||||||||
| 24 | my @output = $w->network( '207.173.0.0' ); | ||||||||||||||||||||||||||||||||
| 25 | foreach my $net (@output) { | ||||||||||||||||||||||||||||||||
| 26 | printf( | ||||||||||||||||||||||||||||||||
| 27 | "%s\t(%s)\t%s\n", | ||||||||||||||||||||||||||||||||
| 28 | $net->OrgName, | ||||||||||||||||||||||||||||||||
| 29 | $net->NetHandle, | ||||||||||||||||||||||||||||||||
| 30 | $net->NetRange, | ||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | # display the network's contact information | ||||||||||||||||||||||||||||||||
| 34 | foreach my $cust ($net->contacts) { | ||||||||||||||||||||||||||||||||
| 35 | printf "Contact: %s (%s)\n", $cust->Name, $cust->Email; | ||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | # lookup an autonomous system number | ||||||||||||||||||||||||||||||||
| 40 | my($asn) = $w->asn( 5650 ); | ||||||||||||||||||||||||||||||||
| 41 | printf "AS5650 was assigned to %s\n", $asn->OrgName; | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | # search for a point-of-contact by handle | ||||||||||||||||||||||||||||||||
| 44 | my @contact = $w->contact('DM2339-ARIN'); | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | my @contact_records = $w->domain('eli.net'); | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | # search for an organization record by the OrgId | ||||||||||||||||||||||||||||||||
| 49 | my @org = $w->organization('FRTR'); | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | # search for a customer record by Handle | ||||||||||||||||||||||||||||||||
| 52 | my @customers = $w->customer('C00823787'); | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | This module provides a Perl interface to the ARIN Whois server. The module takes care of connecting to an ARIN whois server, sending your whois requests, and parsing the whois output. The whois records are returned as lists of Net::Whois::ARIN::* instances. | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | =cut | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 7 | ▶ | use vars qw/ $VERSION /; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 63 | 7 | $VERSION = '0.12'; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 66 | 7 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 67 | 7 | ▶ | use Net::Whois::ARIN::AS; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 68 | 7 | ▶ | use Net::Whois::ARIN::Contact; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 69 | 7 | ▶ | use Net::Whois::ARIN::Customer; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 70 | 7 | ▶ | use Net::Whois::ARIN::Network; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 71 | 7 | ▶ | use Net::Whois::ARIN::Organization; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 7 | my $CONTACT_REGEX = qr/(RTech|Tech|NOC|OrgAbuse|OrgTech|RAbuse|Abuse|Admin)(\w+)/; | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | In the calling conventions below C<[]>'s represent optional parameters. | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | =over 4 | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | =item B<new> - create a Net::Whois::ARIN object | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | my $o = Net::Whois::ARIN->new( | ||||||||||||||||||||||||||||||||
| 84 | [-hostname=> 'whois.arin.net',] | ||||||||||||||||||||||||||||||||
| 85 | [-port => 43,] | ||||||||||||||||||||||||||||||||
| 86 | [-timeout => 45,] | ||||||||||||||||||||||||||||||||
| 87 | [-retries => 3,] | ||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | This is the constuctor for Net::Whois::ARIN. The object returned can be used to query the whois database. | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 95 | 6 | my $class = shift; | |||||||||||||||||||||||||||||||
| 96 | 6 | my %param = @_; | |||||||||||||||||||||||||||||||
| 97 | 6 | my %args; | |||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 6 | foreach (keys %param) { | |||||||||||||||||||||||||||||||
| 100 | 19 | ▶ | if (/^-?host(?:name)?$/i) { $args{'host'} = $param{$_} } | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 101 | 6 | elsif (/^-?port$/i) { $args{'port'} = $param{$_} } | |||||||||||||||||||||||||||||||
| 102 | 6 | elsif (/^-?timeout$/i) { $args{'timeout'} = $param{$_} } | |||||||||||||||||||||||||||||||
| 103 | 1 | elsif (/^-?retries$/i) { $args{'retries'} = $param{$_} } | |||||||||||||||||||||||||||||||
| 104 | else { | ||||||||||||||||||||||||||||||||
| 105 | 0 | carp("$_ is not a valid argument to ${class}->new()"); | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | my $self = bless { | ||||||||||||||||||||||||||||||||
| 110 | '_host' => $args{'host'} || 'whois.arin.net', | ||||||||||||||||||||||||||||||||
| 111 | '_port' => $args{'port'} || 43, | ||||||||||||||||||||||||||||||||
| 112 | '_timeout' => $args{'timeout'}, | ||||||||||||||||||||||||||||||||
| 113 | 6 | ▶ | '_retries' => $args{'retries'} || 3, | ||||||||||||||||||||||||||||||
|
Condition66%4/6
$args{'host'} || 'whois.arin.net'
$args{'port'} || 43
$args{'retries'} || 3
MC/DC0%0/1
$args{'host'} || 'whois.arin.net'
$args{'host'}
MC/DC0%0/1
$args{'port'} || 43
$args{'port'}
MC/DC100%1/1
$args{'retries'} || 3
$args{'retries'}
Truth table50%1/2
A
A= $args{'host'}
Truth table50%1/2
A
A= $args{'port'}
Truth table100%2/2
A
A= $args{'retries'}
| |||||||||||||||||||||||||||||||||
| 114 | }, $class; | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 6 | return $self; | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub _connect { | ||||||||||||||||||||||||||||||
|
Subroutine
_connect: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 120 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 121 | 0 | my $host = $self->{'_host'}; | |||||||||||||||||||||||||||||||
| 122 | 0 | my $port = $self->{'_port'}; | |||||||||||||||||||||||||||||||
| 123 | 0 | my $retries = $self->{'_retries'}; | |||||||||||||||||||||||||||||||
| 124 | 0 | my $sock = undef; | |||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $sock and --$retries
MC/DC0%0/2
not $sock and --$retries
not $sock
--$retries
Truth table0%0/3
not(A) and B
A= not $sockB= --$retries
| |||||||||||||||||||||||||||||||||
| 127 | $sock = IO::Socket::INET->new( | ||||||||||||||||||||||||||||||||
| 128 | PeerHost => $host, | ||||||||||||||||||||||||||||||||
| 129 | PeerPort => $port, | ||||||||||||||||||||||||||||||||
| 130 | Proto => 'tcp', | ||||||||||||||||||||||||||||||||
| 131 | ( ( defined $self->{'_timeout'} ) | ||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | ? ('Timeout' => $self->{'_timeout'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | : (), | ||||||||||||||||||||||||||||||||
| 134 | ), | ||||||||||||||||||||||||||||||||
| 135 | ) | ||||||||||||||||||||||||||||||||
| 136 | } while (!$sock && --$retries); | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | unless ($sock) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if($error eq 'IO::Socket::INET: ') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | 0 | $error = 'connection time out'; | |||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | 0 | croak "can't connect to ${host}\[$port\]: $error"; | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 0 | $sock->autoflush(); | |||||||||||||||||||||||||||||||
| 147 | 0 | return $sock; | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | =item B<query> - make a raw query to the whois server | ||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | my @output = $o->query('207.173.112.0'); | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | =cut | ||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | # open connection, send a whois query, close connection, return whois response | ||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub query { | ||||||||||||||||||||||||||||||
|
Subroutine
query: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 158 | 0 | my($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 159 | 0 | my $s = $self->_connect(); | |||||||||||||||||||||||||||||||
| 160 | 0 | print $s '' . $query . "\x0d\x0a"; | |||||||||||||||||||||||||||||||
| 161 | 0 | local $/; | |||||||||||||||||||||||||||||||
| 162 | 0 | my $results = <$s>; | |||||||||||||||||||||||||||||||
| 163 | 0 | undef $s; | |||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return (wantarray) ? split(/\n/, $results) : $results; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | =item B<network> - request a network record | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | my @records = $o->network('207.173.112.0'); | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | This method requires a single argument. The argument indicates the network to use in the whois lookup. The method returns a list of Net::Whois::ARIN::Network records that matched your search criteria. | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub network { | ||||||||||||||||||||||||||||||
|
Subroutine
network: called CC=9 SCAR=22.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 176 | 1 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 177 | 1 | my @output = $self->query("n + $query"); | |||||||||||||||||||||||||||||||
| 178 | 1 | my @contacts; | |||||||||||||||||||||||||||||||
| 179 | my @records; | ||||||||||||||||||||||||||||||||
| 180 | 1 | my %attributes; | |||||||||||||||||||||||||||||||
| 181 | 1 | my $record_count = 0; | |||||||||||||||||||||||||||||||
| 182 | 1 | my $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 183 | 1 | foreach (@output) { | |||||||||||||||||||||||||||||||
| 184 | 31 | ▶ | next unless $_ =~ /^(\S+):\s+(.*)$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 185 | 24 | my ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||||||
| 186 | 24 | $value =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | 24 | ▶ | if ($key eq 'OrgName' || $key eq 'CustName') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq "OrgName" or $key eq "CustName"
MC/DC50%1/2
$key eq "OrgName" or $key eq "CustName"
$key eq "OrgName"
$key eq "CustName"
Truth table66%2/3
A or B
A= $key eq "OrgName"B= $key eq "CustName"
| |||||||||||||||||||||||||||||||||
| 189 | 1 | $record_count++; | |||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | unless ($record_count > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | 1 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 192 | 1 | next; | |||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | 0 | my $net = Net::Whois::ARIN::Network->new( %attributes ); | |||||||||||||||||||||||||||||||
| 195 | 0 | $net->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 196 | 0 | push @records, $net; | |||||||||||||||||||||||||||||||
| 197 | 0 | $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 198 | 0 | @contacts = (); | |||||||||||||||||||||||||||||||
| 199 | 0 | %attributes = (); | |||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 23 | ▶ | if ($key =~ /^$CONTACT_REGEX$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 203 | 8 | $found_contact_info ++; | |||||||||||||||||||||||||||||||
| 204 | 8 | ▶ | if ($2 eq 'Handle') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | 2 | my @data = $self->contact( $value );; | |||||||||||||||||||||||||||||||
| 206 | 2 | push @contacts, @data; | |||||||||||||||||||||||||||||||
| 207 | 2 | $contacts[-1]->Type( $1 ); | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | elsif( !$found_contact_info ) { | ||||||||||||||||||||||||||||||||
| 211 | 15 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 1 | my $net = Net::Whois::ARIN::Network->new( %attributes ); | |||||||||||||||||||||||||||||||
| 216 | 1 | $net->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 217 | 1 | push @records, $net; | |||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 1 | return @records; | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | =item B<asn> - request an ASN record | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | my @record = $o->asn(5650); | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | This method requires a single argument. The argument indicates the autonomous system number to use in the whois lookup. The method returns a list of Net::Whois::ARIN::AS objects. | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | =cut | ||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | sub asn { | ||||||||||||||||||||||||||||||
|
Subroutine
asn: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 231 | 1 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 232 | 1 | my @output = $self->query("a + $query"); | |||||||||||||||||||||||||||||||
| 233 | 1 | my(%attributes, @contacts); | |||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | 1 | foreach ( @output ) { | |||||||||||||||||||||||||||||||
| 236 | 35 | ▶ | next unless $_ =~ /^(\S+):\s+(.*)$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 237 | 26 | my ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||||||
| 238 | 26 | $value =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 239 | 26 | ▶ | if ($key eq 'Address') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 240 | 1 | $attributes{Address} .= "$value\n"; | |||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||
| 242 | elsif( $key =~ /^$CONTACT_REGEX$/ ) { | ||||||||||||||||||||||||||||||||
| 243 | 12 | ▶ | if ($2 eq 'Handle') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | 3 | push @contacts, $self->contact( $value ); | |||||||||||||||||||||||||||||||
| 245 | 3 | $contacts[-1]->Type( $1 ); | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | else { | ||||||||||||||||||||||||||||||||
| 249 | 13 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||
| 253 | chomp( $attributes{Address} ) | ||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | if exists $attributes{Address}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | 1 | my $as = Net::Whois::ARIN::AS->new( %attributes ); | |||||||||||||||||||||||||||||||
| 257 | 1 | $as->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 258 | 1 | return $as; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | =item B<organization> - request an organization record | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | my @record = $w->org('ELIX'); | ||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | =cut | ||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | 1 | ▶ | sub organization { | ||||||||||||||||||||||||||||||
|
Subroutine
organization: called CC=10 SCAR=23.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 268 | 1 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 269 | 1 | my @output = $self->query("o + $query"); | |||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 1 | my @records; | |||||||||||||||||||||||||||||||
| 272 | 1 | my(%attributes, @contacts); | |||||||||||||||||||||||||||||||
| 273 | 1 | my $record_count = 0; | |||||||||||||||||||||||||||||||
| 274 | 1 | my $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | 1 | foreach ( @output ) { | |||||||||||||||||||||||||||||||
| 277 | 31 | ▶ | next unless $_ =~ /^(\S+):\s+(.*)$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 278 | 23 | my ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||||||
| 279 | 23 | $value =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | 23 | ▶ | if ($key eq 'OrgName') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 282 | 1 | $record_count++; | |||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | unless ($record_count > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | 1 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 285 | 1 | next; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | 0 | my $org = Net::Whois::ARIN::Organization->new( %attributes ); | |||||||||||||||||||||||||||||||
| 288 | 0 | $org->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 289 | 0 | push @records, $org; | |||||||||||||||||||||||||||||||
| 290 | 0 | $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 291 | 0 | @contacts = (); | |||||||||||||||||||||||||||||||
| 292 | 0 | %attributes = (); | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | 22 | ▶ | if ($key eq 'Address') { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 295 | 1 | $attributes{Address} .= "$value\n"; | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | elsif( $key =~ /^$CONTACT_REGEX$/ ) { | ||||||||||||||||||||||||||||||||
| 298 | 12 | $found_contact_info ++; | |||||||||||||||||||||||||||||||
| 299 | 12 | ▶ | if ($2 eq 'Handle') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | 3 | push @contacts, $self->contact( $value ); | |||||||||||||||||||||||||||||||
| 301 | 3 | $contacts[-1]->Type( $1 ); | |||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||
| 304 | elsif( !$found_contact_info ) { | ||||||||||||||||||||||||||||||||
| 305 | 9 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | chomp( $attributes{Address} ) | ||||||||||||||||||||||||||||||||
| 310 | 1 | ▶ | if exists $attributes{Address}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | 1 | my $org = Net::Whois::ARIN::Organization->new( %attributes ); | |||||||||||||||||||||||||||||||
| 313 | 1 | $org->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 314 | 1 | push @records, $org; | |||||||||||||||||||||||||||||||
| 315 | 1 | return @records; | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | =item B<customer> - request a customer record | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | my @records = $w->customer('ELIX'); | ||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||
| 322 | =cut | ||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | sub customer { | ||||||||||||||||||||||||||||||
|
Subroutine
customer: called CC=10 SCAR=23.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 325 | 1 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 326 | 1 | my @output = $self->query("c + $query"); | |||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 1 | my @records; | |||||||||||||||||||||||||||||||
| 329 | 1 | my(%attributes, @contacts); | |||||||||||||||||||||||||||||||
| 330 | 1 | my $record_count = 0; | |||||||||||||||||||||||||||||||
| 331 | 1 | my $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||
| 333 | 1 | foreach ( @output ) { | |||||||||||||||||||||||||||||||
| 334 | 27 | ▶ | next unless $_ =~ /^(\S+):\s+(.*)$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 335 | 21 | my ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||||||
| 336 | 21 | $value =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | 21 | ▶ | if ($key eq 'CustName') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | 1 | $record_count++; | |||||||||||||||||||||||||||||||
| 340 | 1 | ▶ | unless ($record_count > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 341 | 1 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 342 | 1 | next; | |||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | 0 | my $cust = Net::Whois::ARIN::Customer->new( %attributes ); | |||||||||||||||||||||||||||||||
| 345 | 0 | $cust->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 346 | 0 | push @records, $cust; | |||||||||||||||||||||||||||||||
| 347 | 0 | $found_contact_info = 0; | |||||||||||||||||||||||||||||||
| 348 | 0 | @contacts = (); | |||||||||||||||||||||||||||||||
| 349 | 0 | %attributes = (); | |||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | 20 | ▶ | if ($key eq 'Address') { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 353 | 1 | $attributes{Address} .= "$value\n"; | |||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||
| 355 | elsif( $key =~ /^$CONTACT_REGEX$/ ) { | ||||||||||||||||||||||||||||||||
| 356 | 4 | $found_contact_info ++; | |||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | if ($2 eq 'Handle') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | # do a whois lookup for point of contact information | ||||||||||||||||||||||||||||||||
| 359 | 1 | my @data = $self->contact($value); | |||||||||||||||||||||||||||||||
| 360 | 1 | push @contacts, @data; | |||||||||||||||||||||||||||||||
| 361 | 1 | $contacts[-1]->Type( $1 ); | |||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||
| 364 | elsif( !$found_contact_info ) { | ||||||||||||||||||||||||||||||||
| 365 | 15 | $attributes{$key} = $value; | |||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | chomp( $attributes{Address} ) | ||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | if exists $attributes{Address}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | 1 | my $cust = Net::Whois::ARIN::Customer->new( %attributes ); | |||||||||||||||||||||||||||||||
| 373 | 1 | $cust->contacts( @contacts ); | |||||||||||||||||||||||||||||||
| 374 | 1 | push @records, $cust; | |||||||||||||||||||||||||||||||
| 375 | 1 | return @records; | |||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | =item B<contact> - request a point-of-contact record | ||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | my @record = $w->contact('DM2339-ARIN'); | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | =cut | ||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||
| 384 | 10 | ▶ | sub contact { | ||||||||||||||||||||||||||||||
|
Subroutine
contact: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 385 | 10 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 386 | 10 | my @output = $self->query("p + $query"); | |||||||||||||||||||||||||||||||
| 387 | 10 | my @records; | |||||||||||||||||||||||||||||||
| 388 | 10 | my $n = -1; | |||||||||||||||||||||||||||||||
| 389 | 10 | foreach ( @output ) { | |||||||||||||||||||||||||||||||
| 390 | 140 | ▶ | next unless $_ =~ /^(\S+):\s+(.*)$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 391 | 112 | my ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||||||
| 392 | 112 | $value =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 393 | # $records[++$n] = {} if /^(Name):/; | ||||||||||||||||||||||||||||||||
| 394 | 112 | ▶ | $records[++$n] = {} if $n < 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 395 | 112 | ▶ | if ($key eq 'Address') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 396 | 14 | $records[$n]->{Address} .= "$value\n"; | |||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||
| 398 | else { | ||||||||||||||||||||||||||||||||
| 399 | 98 | $records[$n]->{$key} = $value; | |||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||
| 403 | 10 | my @contacts; | |||||||||||||||||||||||||||||||
| 404 | 10 | foreach ( @records ) { | |||||||||||||||||||||||||||||||
| 405 | 7 | my %attributes = %$_; | |||||||||||||||||||||||||||||||
| 406 | chomp($attributes{Address}) | ||||||||||||||||||||||||||||||||
| 407 | 7 | ▶ | if exists $attributes{Address}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 408 | 7 | push @contacts, Net::Whois::ARIN::Contact->new( %attributes ); | |||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | 10 | return @contacts; | |||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||
| 414 | =item B<domain> - request all records from a given domain | ||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | @output = $w->domain('eli.net'); | ||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | =back | ||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | =cut | ||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub domain { | ||||||||||||||||||||||||||||||
|
Subroutine
domain: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 423 | 0 | my ($self, $query) = @_; | |||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | $query = "\@$query" if $query !~ /^\@/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 425 | 0 | $query = "+ $query"; | |||||||||||||||||||||||||||||||
| 426 | 0 | my @output = $self->query($query); | |||||||||||||||||||||||||||||||
| 427 | 0 | my @contacts; | |||||||||||||||||||||||||||||||
| 428 | my %attr; | ||||||||||||||||||||||||||||||||
| 429 | 0 | foreach (@output) { | |||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | if(/^(\S+):\s+(.*)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 431 | 0 | $attr{$1} = $2; | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if(/^Email:\s+.*$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 434 | 0 | push @contacts, Net::Whois::ARIN::Contact->new( %attr ); | |||||||||||||||||||||||||||||||
| 435 | 0 | %attr = (); | |||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||
| 438 | 0 | return @contacts; | |||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||
| 443 | L<Net::Whois::ARIN::AS> | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | L<Net::Whois::ARIN::Network> | ||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||
| 447 | L<Net::Whois::ARIN::Contact> | ||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||
| 449 | L<Net::Whois::ARIN::Organization> | ||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | L<Net::Whois::ARIN::Customer> | ||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||
| 455 | Todd Caine <todd.caine at gmail.com> | ||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||
| 457 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||
| 459 | Copyright (c) 2004-2011 Todd Caine. All rights reserved. | ||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||
| 461 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | =cut | ||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||
| 466 | 7 | 1; | |||||||||||||||||||||||||||||||
| 467 | __END__ | ||||||||||||||||||||||||||||||||