ParseWhois.pm

filter: Statementstmt 40.0% 24 / 60 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 46.1% 6 / 13 Podpod 0.0% 0 / 4 totaltotal 30.6% 30 / 98 CC 12 SCAR 27.9
CC
12
Cov
30%
_connect
42.0
_send_to_sock
20.0
debug
12.0
CRAP 16.3
« ParseWhois/Domain/Registrar/SRSPlus.pm ↑ Summary ParseWhois/Domain/Registrar/Registrars.pm »
1 package Net::ParseWhois;
2 1 require 5.004;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Net::ParseWhois::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 $VERSION = '0.7';
12  
13 1 require Exporter;
14  
15 1 @ISA = qw(Exporter);
16 1 @EXPORT = ();
17  
18 0 ▶sub debug {
Subroutine debug: not called CC=3 SCAR=24.8
Pod undocumented
19 0 my $self = shift;
20 0 my $opt = shift;
21 0 ▶ $self->{'debug'} = $opt if ($opt);
Branch: 1 branch
BranchTrueFalseTotal
if $opt 0 0 0
22 0 ▶ return $self->{'debug'} || 0;
Condition0%0/2
$self->{'debug'} || 0
l!l
00
MC/DC0%0/1
$self->{'debug'} || 0
$self->{'debug'}
Truth table0%0/2
A
A= $self->{'debug'}
Aresult
11
00
23 }
24  
25 # Mapping of whois servers to Top-Level domains. Originally quite sparse,
26 # these all pointed to whois.nsiregistry.com. --jcm
27 0 ▶sub TLDs {
Subroutine TLDs: not called CC=1 SCAR=6.9
Pod undocumented
28 {
29 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 0 ▶sub TLDModel {
Subroutine TLDModel: not called CC=1 SCAR=6.9
Pod undocumented
43 {
44 0 COM => 'thin',
45 NET => 'thin',
46 ORG => 'thick',
47 EDU => 'thick',
48 GOV => 'thick',
49 MIL => 'thick'
50 }
51 }
52  
53  
54 0 ▶sub _connect {
Subroutine _connect: not called CC=6 SCAR=37.4
55 0 my $self = shift;
56  
57 0 ▶ unless ($self->{'base_server_addr'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"base_server_addr"}) 0 0 0
58 0 my $a = gethostbyname $self->{'base_server_name'};
59 0 ▶ $self->{'base_server_addr'} = inet_ntoa($a) if $a;
Branch: 1 branch
BranchTrueFalseTotal
if $a 0 0 0
60 }
61  
62 0 ▶ $self->{'base_server_addr'} or croak 'Net::ParseWhois:: no server';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"base_server_addr"} or croak("Net::ParseWhois:: no server") 0 0 0
63  
64 0 ▶ warn "connecting to $self->{'base_server_addr'} 43\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
65  
66 0 ▶ my $sock = IO::Socket::INET->new(PeerAddr => $self->{'base_server_addr'},
Branch: 1 branch
BranchTrueFalseTotal
my $sock = "IO::Socket::INET"->new("PeerAddr", $self->{"base_server_addr"}, "PeerPort", "whois", "Proto", "tcp") or croak(qq[Net::ParseWhois: Can't connect to $self->{"base_server_name"}: $@]) 0 0 0
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 0 ▶sub _load_module {
Subroutine _load_module: not called CC=2 SCAR=17.9
75 0 my ($self, $module) = @_;
76 0 eval "use $module";
77 0 ▶ die "failed to load $module\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
78 }
79  
80 0 ▶sub _send_to_sock {
Subroutine _send_to_sock: not called CC=4 SCAR=30.0
81 0 my $self = shift;
82 0 my $sock = shift;
83 0 my $text_to_send = shift;
84 0 my $sock_text;
85  
86 0 ▶ unless ($text_to_send) {
Branch: 1 branch
BranchTrueFalseTotal
if ($text_to_send) { } 0 0 0
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>;
94 }
95 0 undef $sock;
96 0 ▶ $sock_text || die "No data returned from $self->{'base_server_name'}\n";
Branch: 1 branch
BranchTrueFalseTotal
$sock_text or die qq[No data returned from $self->{"base_server_name"}\n] 0 0 0
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
100 0 return \@text;
101 }
102  
103  
104  
105 0 ▶sub US_State {
Subroutine US_State: not called CC=1 SCAR=6.9
Pod undocumented
106 {
107 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 1;
167  
168  
169 __END__
« ParseWhois/Domain/Registrar/SRSPlus.pm ↑ Summary ParseWhois/Domain/Registrar/Registrars.pm »