line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ParseWhois; |
2
|
|
|
|
|
|
|
require 5.004; |
3
|
1
|
|
|
1
|
|
641
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
853
|
use IO::Socket; |
|
1
|
|
|
|
|
24341
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
1420
|
use IO::File; |
|
1
|
|
|
|
|
1993
|
|
|
1
|
|
|
|
|
106
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
64
|
|
9
|
1
|
|
|
1
|
|
547
|
use Net::ParseWhois::Domain; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
658
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.7'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
16
|
|
|
|
|
|
|
@EXPORT = (); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub debug { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
my $opt = shift; |
21
|
0
|
0
|
|
|
|
|
$self->{'debug'} = $opt if ($opt); |
22
|
0
|
|
0
|
|
|
|
return $self->{'debug'} || 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Mapping of whois servers to Top-Level domains. Originally quite sparse, |
26
|
|
|
|
|
|
|
# these all pointed to whois.nsiregistry.com. --jcm |
27
|
|
|
|
|
|
|
sub TLDs { |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
0
|
|
COM => 'whois.internic.net', |
30
|
|
|
|
|
|
|
NET => 'whois.internic.net', |
31
|
|
|
|
|
|
|
ORG => 'whois.publicinterestregistry.net', |
32
|
|
|
|
|
|
|
EDU => 'whois.educause.net', |
33
|
|
|
|
|
|
|
GOV => 'whois.nic.gov', |
34
|
|
|
|
|
|
|
MIL => 'whois.nic.mil' |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Mapping of TLDs to their WHOIS model. Basically, this will let us know |
40
|
|
|
|
|
|
|
# if there's any referrals to bother to chase. Generally, we're only going |
41
|
|
|
|
|
|
|
# to chase referrals for .com and .net domains. --jcm, 11/10/05 |
42
|
|
|
|
|
|
|
sub TLDModel { |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
0
|
0
|
|
COM => 'thin', |
45
|
|
|
|
|
|
|
NET => 'thin', |
46
|
|
|
|
|
|
|
ORG => 'thick', |
47
|
|
|
|
|
|
|
EDU => 'thick', |
48
|
|
|
|
|
|
|
GOV => 'thick', |
49
|
|
|
|
|
|
|
MIL => 'thick' |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _connect { |
55
|
0
|
|
|
0
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
unless ($self->{'base_server_addr'}) { |
58
|
0
|
|
|
|
|
|
my $a = gethostbyname $self->{'base_server_name'}; |
59
|
0
|
0
|
|
|
|
|
$self->{'base_server_addr'} = inet_ntoa($a) if $a; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
$self->{'base_server_addr'} or croak 'Net::ParseWhois:: no server'; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
warn "connecting to $self->{'base_server_addr'} 43\n" if $self->debug; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
my $sock = IO::Socket::INET->new(PeerAddr => $self->{'base_server_addr'}, |
67
|
|
|
|
|
|
|
PeerPort => 'whois', |
68
|
|
|
|
|
|
|
Proto => 'tcp') |
69
|
|
|
|
|
|
|
or croak "Net::ParseWhois: Can't connect to $self->{'base_server_name'}: $@"; |
70
|
0
|
|
|
|
|
|
$sock->autoflush; |
71
|
0
|
|
|
|
|
|
return $sock; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _load_module { |
75
|
0
|
|
|
0
|
|
|
my ($self, $module) = @_; |
76
|
0
|
|
|
|
|
|
eval "use $module"; |
77
|
0
|
0
|
|
|
|
|
die "failed to load $module\n" if $@; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _send_to_sock { |
81
|
0
|
|
|
0
|
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
my $sock = shift; |
83
|
0
|
|
|
|
|
|
my $text_to_send = shift; |
84
|
0
|
|
|
|
|
|
my $sock_text; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
unless ($text_to_send) { |
87
|
0
|
|
|
|
|
|
print $sock "$self->{'domain'}\x0d\x0a"; |
88
|
|
|
|
|
|
|
} else { |
89
|
0
|
|
|
|
|
|
print $sock $text_to_send; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
|
|
|
local $/; $sock_text = <$sock>; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
undef $sock; |
96
|
0
|
0
|
|
|
|
|
$sock_text || die "No data returned from $self->{'base_server_name'}\n"; |
97
|
0
|
|
|
|
|
|
$sock_text =~ s/^ +//gm; |
98
|
0
|
|
|
|
|
|
my @text = split / *\x0d?\x0a/, $sock_text; |
99
|
0
|
|
|
|
|
|
for (@text) { s/^ +//} # get rid of leading whitespace |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return \@text; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub US_State { |
106
|
|
|
|
|
|
|
{ |
107
|
0
|
|
|
0
|
0
|
|
AL => 'ALABAMA', |
108
|
|
|
|
|
|
|
AK => 'ALASKA', |
109
|
|
|
|
|
|
|
AZ => 'ARIZONA', |
110
|
|
|
|
|
|
|
AR => 'ARKANSAS', |
111
|
|
|
|
|
|
|
CA => 'CALIFORNIA', |
112
|
|
|
|
|
|
|
CO => 'COLORADO', |
113
|
|
|
|
|
|
|
CT => 'CONNECTICUT', |
114
|
|
|
|
|
|
|
DE => 'DELAWARE', |
115
|
|
|
|
|
|
|
DC => 'DISTRICT OF COLUMBIA', |
116
|
|
|
|
|
|
|
FL => 'FLORIDA', |
117
|
|
|
|
|
|
|
GA => 'GEORGIA', |
118
|
|
|
|
|
|
|
GU => 'GUAM', |
119
|
|
|
|
|
|
|
HI => 'HAWAII', |
120
|
|
|
|
|
|
|
ID => 'IDAHO', |
121
|
|
|
|
|
|
|
IL => 'ILLINOIS', |
122
|
|
|
|
|
|
|
IN => 'INDIANA', |
123
|
|
|
|
|
|
|
IA => 'IOWA', |
124
|
|
|
|
|
|
|
KS => 'KANSAS', |
125
|
|
|
|
|
|
|
KY => 'KENTUCKY', |
126
|
|
|
|
|
|
|
LA => 'LOUISIANA', |
127
|
|
|
|
|
|
|
ME => 'MAINE', |
128
|
|
|
|
|
|
|
MH => 'MARSHALL ISLANDS', |
129
|
|
|
|
|
|
|
MD => 'MARYLAND', |
130
|
|
|
|
|
|
|
MA => 'MASSACHUSETTS', |
131
|
|
|
|
|
|
|
MI => 'MICHIGAN', |
132
|
|
|
|
|
|
|
MN => 'MINNESOTA', |
133
|
|
|
|
|
|
|
MS => 'MISSISSIPPI', |
134
|
|
|
|
|
|
|
MO => 'MISSOURI', |
135
|
|
|
|
|
|
|
MT => 'MONTANA', |
136
|
|
|
|
|
|
|
'NE' => 'NEBRASKA', # nebraska ne 'a real state', heh |
137
|
|
|
|
|
|
|
NV => 'NEVADA', |
138
|
|
|
|
|
|
|
NH => 'NEW HAMPSHIRE', |
139
|
|
|
|
|
|
|
NJ => 'NEW JERSEY', |
140
|
|
|
|
|
|
|
NM => 'NEW MEXICO', |
141
|
|
|
|
|
|
|
NY => 'NEW YORK', |
142
|
|
|
|
|
|
|
NC => 'NORTH CAROLINA', |
143
|
|
|
|
|
|
|
ND => 'NORTH DAKOTA', |
144
|
|
|
|
|
|
|
MP => 'NORTHERN MARIANA ISLANDS', |
145
|
|
|
|
|
|
|
OH => 'OHIO', |
146
|
|
|
|
|
|
|
OK => 'OKLAHOMA', |
147
|
|
|
|
|
|
|
OR => 'OREGON', |
148
|
|
|
|
|
|
|
PA => 'PENNSYLVANIA', |
149
|
|
|
|
|
|
|
PR => 'PUERTO RICO', |
150
|
|
|
|
|
|
|
RI => 'RHODE ISLAND', |
151
|
|
|
|
|
|
|
SC => 'SOUTH CAROLINA', |
152
|
|
|
|
|
|
|
SD => 'SOUTH DAKOTA', |
153
|
|
|
|
|
|
|
TN => 'TENNESSEE', |
154
|
|
|
|
|
|
|
TX => 'TEXAS', |
155
|
|
|
|
|
|
|
UT => 'UTAH', |
156
|
|
|
|
|
|
|
VT => 'VERMONT', |
157
|
|
|
|
|
|
|
VI => 'VIRGIN ISLANDS', |
158
|
|
|
|
|
|
|
VA => 'VIRGINIA', |
159
|
|
|
|
|
|
|
WA => 'WASHINGTON', |
160
|
|
|
|
|
|
|
WV => 'WEST VIRGINIA', |
161
|
|
|
|
|
|
|
WI => 'WISCONSIN', |
162
|
|
|
|
|
|
|
WY => 'WYOMING', |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__END__ |