ParseWhois/Domain/Registrar.pm

filter: Statementstmt 5.3% 13 / 242 Branchbran 1.0% 2 / 188 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 10.7% 3 / 28 Podpod 0.0% 0 / 27 totaltotal 3.5% 18 / 514 CC 109 SCAR 51.4
CC
109
Cov
3%
parse_contacts
462.0
parse_nameservers
380.0
parse_start
156.0
CRAP 171.4
« ParseWhois/Domain.pm ↑ Summary ParseWhois/Domain/Registrar/BulkRegister.pm »
1 # Program: Net::ParseWhois base registrar class
2 # Version: 0.2
3 # Purpose: Provides the base class definition for all the registrar
4 # sub-classes. Methods defined here are over-ridden by the child
5 # classes as needed for each particular registrar. By default,
6 # this base class attempts to parse output of a Network Solutions
7 # WHOIS server.
8 # Updated: 11/21/2005 by Jeff Mercer <riffer@vaxer.net>
9  
10 package Net::ParseWhois::Domain::Registrar;
11 1 require 5.004;
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 $Net::ParseWhois::Domain::Registrar::VERSION = 0.2;
15 1 @Net::ParseWhois::Domain::Registrar::ISA = qw(Net::ParseWhois::Domain);
16  
17 # used by new to import vals into $self->{} in specific registrar classes
18 1 ▶sub my_data {}
Subroutine my_data: called CC=1 SCAR=0.0
Pod undocumented
19  
20 0 ▶sub registrar_data {
Subroutine registrar_data: not called CC=1 SCAR=6.9
Pod undocumented
21 {
22 0 'whois.dotster.com' => {
23 'registrar_tag' => 'DOTSTER, INC.',
24 'referral_tag' => 'http://www.dotster.com/help/whois',
25 'class' => 'Dotster' },
26 'whois.register.com' => {
27 'registrar_tag' => 'REGISTER.COM, INC.',
28 'referral_tag' => 'www.register.com',
29 'class' => 'Register' },
30 'whois.networksolutions.com' => {
31 'registrar_tag' => 'NETWORK SOLUTIONS, INC.',
32 'referral_tag' => 'www.networksolutions.com',
33 'class' => 'Netsol' },
34 'whois.opensrs.net' => {
35 'registrar_tag' => 'TUCOWS.COM, INC.',
36 'referral_tag' => 'www.opensrs.net',
37 'class' => 'OpenSRS' },
38 'whois.domaindiscover.com' => {
39 'registrar_tag' => 'TIERRANET, INC.',
40 'referral_tag' => 'www.domaindiscover.com',
41 'class' => 'DomainDiscover' },
42 'whois.bulkregister.com' => {
43 'registrar_tag' => 'BULKREGISTER.COM, INC.',
44 'referral_tag' => 'www.bulkregister.com',
45 'class' => 'BulkRegister' },
46 'rs.domainbank.net' => {
47 'registrar_tag' => 'DOMAIN BANK, INC.',
48 'referral_tag' => 'www.domainbank.net',
49 'class' => 'DomainBank' },
50 'whois.registrars.com' => {
51 'registrar_tag' => 'INTERNET DOMAIN REGISTRARS',
52 'referral_tag' => 'www.registrars.com',
53 'class' => 'Registrars' },
54 'whois.corenic.net' => {
55 'registrar_tag' => 'CORE INTERNET COUNCIL OF REGISTRARS',
56 'referral_tag' => 'www.corenic.net',
57 'class' => 'CoreNic' },
58 'whois.melbourneit.com' => {
59 'registrar_tag' => 'MELBOURNE IT, LTD. D/B/A INTERNET NAMES WORLDWIDE',
60 'referral_tag' => 'www.InternetNamesWW.com',
61 'class' => 'INameWW' },
62 'whois.easyspace.com' => {
63 'registrar_tag' => 'EASYSPACE LTD',
64 'referral_tag' => 'www.easyspace.com',
65 'class' => 'Easyspace' },
66 'whois.publicinterestregistry.net' => {
67 'registrar_tag' => 'PUBLIC INTEREST REGISTRY',
68 'referral_tag' => 'www.pir.org',
69 'class' => 'PIR' },
70 'whois.srsplus.com' => {
71 'registrar_tag' => 'TLDs, LLC',
72 'referral_tag' => 'www.srsplus.com',
73 'class' => 'SRSPlus' },
74 'whois.godaddy.com' => {
75 'registrar_tag' => 'GO DADDY SOFTWARE, INC.',
76 'referral_tag' => 'www.godaddy.com',
77 'class' => 'GoDaddy' },
78 'whois.enom.com' => {
79 'registrar_tag' => 'ENOM, INC.',
80 'referral_tag' => 'www.enom.com',
81 'class' => 'Enom' },
82 'whois.namesecure.com' => {
83 'registrar_tag' => 'NAMESECURE LLC',
84 'referral_tag' => 'www.namesecure.com',
85 'class' => 'NameSecure' },
86 'whois.namejuice.com' => {
87 'registrar_tag' => 'DOMAIN REGISTRY GROUP INC',
88 'referral_tag' => 'www.namejuice.com',
89 'class' => 'NameJuice' },
90 'whois.namescout.com' => {
91 'registrar_tag' => 'NAMESCOUT CORP',
92 'referral_tag' => 'www.namescout.com',
93 'class' => 'NameScout' },
94 'unknown_registrar' => {
95 'registrar_tag' => 'Unknown',
96 'referral_tag' => 'n/a',
97 'class' => 'Unknown' }
98 }
99 # see perldoc Net::ParseWhois section 'REGISTRARS'
100 }
101  
102  
103 # Try and parse out all the garbage before the actual domain registration
104 # info. Mostly skipping useless legal boilerplate and the like. --jcm
105 0 ▶sub parse_start {
Subroutine parse_start: not called CC=12 SCAR=50.5
Pod undocumented
106 # Initialization
107 0 my $self = shift;
108 0 my $text = shift;
109 0 my $t = shift @{ $text };
110 0 ▶ warn "DEBUG: parse_start() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
111  
112 # Keep going through raw text until we find our starting point
113 0 ▶ until (!defined $t || $t =~ /$self->{'regex_org_start'}/ ||
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $t or $t =~ /$self->{"regex_org_start"}/ or $t =~ /$self->{"regex_no_match"}/) 0 0 0
Condition0%0/6
not defined $t or $t =~ /$self->{"regex_org_start"}/ or $t =~ /$self->{"regex_no_match"}/
l!l&&r!l&&!r
000
not defined $t or $t =~ /$self->{"regex_org_start"}/
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $t or $t =~ /$self->{"regex_org_start"}/ or $t =~ /$self->{"regex_no_match"}/
not defined $t $t =~ /$self->{"regex_org_start"}/ $t =~ /$self->{"regex_no_match"}/
Truth table0%0/4
not(A) or B or C
A= not defined $tB= $t =~ /$self->{"regex_org_start"}/C= $t =~ /$self->{"regex_no_match"}/
ABCresult
1XX1
01X1
0011
0000
114 0 $t =~ /$self->{'regex_no_match'}/) { $t = shift @{$text}; }
115  
116 #trim leading whitespace
117 0 $t =~ s/^\s//;
118  
119 # Skip to next line if this line is blank
120 0 ▶ $t = shift @{ $text } if ($t eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $t eq "" 0 0 0
121  
122 # If we find a match for the start of registrant data...
123 0 ▶ if ($t =~ /$self->{'regex_org_start'}/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($t =~ /$self->{'regex_org_start'}/) { } 0 0 0
elsif ($t =~ /$self->{'regex_no_match'}/) { } 0 0 0
124 # Prep the next input line and mark as a Match
125 0 $t = shift @{ $text };
126 0 $self->{'MATCH'} = 1;
127 # since we have a referral, this should never get caught. --aai
128 } elsif ($t =~ /$self->{'regex_no_match'}/) {
129 0 $self->{'MATCH'} = 0;
130 }
131  
132 # Did we find a match?
133 0 ▶ if ($self->{'MATCH'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MATCH"}) 0 0 0
134 # Attempt to parse out registrant name, and tag if any
135 0 ▶ if ($t =~ /^(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /^(.*)$/) { } 0 0 0
136 0 $self->{'NAME'} = $1;
137 0 ▶ if ($self->{'NAME'} =~ /^(.*)\s+\((\S+)\)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"NAME"} =~ /^(.*)\s+\((\S+)\)$/) 0 0 0
138 0 $self->{'NAME'} = $1;
139 0 $self->{'TAG'} = $2;
140 }
141 } else {
142 0 die "Registrant Name not found in returned information\n";
143 }
144 }
145  
146 0 ▶ warn "DEBUG: parse_start() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
147 }
148  
149  
150 # Attempt to parse the organizational entity that has registered the domain.
151 # (I.E. the domain owner or registrant)
152 0 ▶sub parse_org {
Subroutine parse_org: not called CC=11 SCAR=48.8
Pod undocumented
153 # Initialization
154 0 my $self = shift;
155 0 my $text = shift;
156 0 my (@t, $c, $t);
157 0 @t = ();
158 0 ▶ warn "DEBUG: parse_org() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
159  
160 # read in text until next empty line
161 0 ▶ push @t, shift @{ $text } while ${ $text }[0];
Branch: 1 branch
BranchTrueFalseTotal
do { $text }->[0] and do { push @t, shift @{$text;} } 0 0 0
162  
163 # If a position for country info (in the registrant block) is defined
164 0 ▶ if ($self->{'my_country_position'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'my_country_position'}) { } 0 0 0
165 # Extract country info
166 0 $t = $t[$#t - $self->{'my_country_position'}];
167 } else {
168 # Set $t to the last line in the array, which will be the
169 # last line before a blank line.
170 0 $t = $t[$#t];
171 }
172  
173 # Try and figure out appropriate country code, if available
174 0 ▶ if (!defined $t) {
Branch: 5 branches
BranchTrueFalseTotal
if (not defined $t) { } 0 0 0
elsif ($t =~ /^(?:usa|u\.\s*s\.\s*a\.)$/i) { } 0 0 0
elsif ($self->code2country($t)) { } 0 0 0
elsif ($c = $self->country2code($t)) { } 0 0 0
elsif ($t =~ /,\s*([^,]+?)(?:\s+\d{5}(?:-\d{4})?)?$/) { } 0 0 0
175 # do nothing
176 # USA! USA!
177 } elsif ($t =~ /^(?:usa|u\.\s*s\.\s*a\.)$/i) {
178 0 pop @t;
179 0 $t = 'US';
180 } elsif ($self->code2country($t)) {
181 0 pop @t;
182 0 $t = uc $t;
183 } elsif ($c = $self->country2code($t)) {
184 0 pop @t;
185 0 $t = uc $c;
186 } elsif ($t =~ /,\s*([^,]+?)(?:\s+\d{5}(?:-\d{4})?)?$/) {
187 # TODO - regex is too rigid. lots of times this shouldn't be matched
188 # because a tel/fax line exists after address3/city,state zip ..
189 0 ▶ $t = $self->US_State->{uc $1} ? 'US' : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->US_State->{uc $1} ? : 0 0 0
190 } else {
191 0 undef $t;
192 }
193  
194 # Return registrant address and country info
195 0 $self->{ADDRESS} = [@t];
196 0 $self->{COUNTRY} = $t;
197  
198 0 ▶ warn "DEBUG: parse_org() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
199 }
200  
201 # Try and parse out all the contacts data. This is rather loose in that it
202 # doesn't do any sub-parsing but just returns fat blocks of data. A future
203 # improvement would be to break it down into name, e-mail, address, etc.
204 # --jcm
205 0 ▶sub parse_contacts {
Subroutine parse_contacts: not called CC=21 SCAR=61.4
Pod undocumented
206 # Initialization
207 0 my ($self, $text) = @_;
208 0 my ($done, $t, $blah, $ck);
209 0 my (@ctypes, @c);
210 0 ▶ warn "DEBUG: parse_contacts() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
211  
212 # As long as we have text to eat...
213 0 ▶ while (@{ $text }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$text;}) 0 0 0
214 # Check to see if all the contacts have been filled in
215 0 $done = 1;
216 0 foreach $ck (@{ $self->{'my_contacts'} }) {
217 0 ▶ warn "DEBUG: ck=$ck\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
218 0 ▶ unless ($self->{CONTACTS}->{uc($ck)}) { $done = 0; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"CONTACTS"}{uc $ck}) 0 0 0
219 }
220 0 ▶ last if $done;
Branch: 1 branch
BranchTrueFalseTotal
if $done 0 0 0
221  
222 # Grab next line of test, skip it if blank
223 0 $t = shift(@{ $text });
224 0 ▶ warn "DEBUG: t = $t\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
225 0 ▶ next if $t=~ /^$/;
Branch: 1 branch
BranchTrueFalseTotal
if $t =~ /^$/ 0 0 0
226  
227  
228 # If this line is a contact header...
229 0 ▶ if ($t =~ /contact.*:$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /contact.*:$/i) 0 0 0
230 # Figure out what contact type(s) it's for
231 0 ▶ warn "DEBUG: Matched against /contact.*:/ regex\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
232 0 @ctypes = ($t =~ /\b(\S+) contact/ig);
233 0 @c=();
234 0 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 0 0
235 0 ▶ printf "DEBUG: ctypes=%d\n", $#ctypes+1 if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
236 0 foreach (@ctypes) {
237 0 warn "DEBUG: ctypes contains=$_\n";
238 }
239 }
240  
241 # Uh... Not sure what the point of this is. --jcm, 11/16/05
242 0 ▶ if ($self->{'my_contacts_extra_line'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"my_contacts_extra_line"}) 0 0 0
243 0 $blah = shift(@{ $text });
244 }
245  
246 # Eat all the text until the next contact line and
247 # store it in hash
248 0 ▶ while ( ${ $text }[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (do { $text }->[0]) 0 0 0
249 0 ▶ warn "DEBUG: text[0]=${$text}[0]\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
250 0 ▶ last if ${ $text }[0] =~ /contact.*:$/i;
Branch: 1 branch
BranchTrueFalseTotal
if do { $text }->[0] =~ /contact.*:$/i 0 0 0
251 0 push @c, shift @{ $text };
252 }
253  
254 # Take our contacts hash and map it to our objects
255 # CONTACTS hash. Only I think this is foobar...
256 0 ▶ printf "DEBUG: c=%d\n", $#c+1 if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
257 0 foreach (@ctypes) { @{$self->{CONTACTS}{uc $_}}=@c; }
258 }
259 }
260  
261 0 ▶ warn "DEBUG: parse_contacts() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
262 }
263  
264 # Parse out the nameservers
265 0 ▶sub parse_nameservers {
Subroutine parse_nameservers: not called CC=19 SCAR=59.4
Pod undocumented
266 # Initialization
267 0 my ($self, $text) = @_;
268 0 my ($t, $dns, $key);
269 0 my (@s, @temp);
270 0 ▶ warn "DEBUG: parse_nameservers() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
271 0 ▶ warn "DEBUG: text = $text, size = $#{$text}\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
272  
273 # As long as there's text in the array...
274 0 ▶ warn "DEBUG: Starting text processing loop...\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
275 0 ▶ while (@{ $text }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$text;}) 0 0 0
276 # Done if we've got the nameservers already
277 0 ▶ if ($self->{SERVERS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"SERVERS"}) 0 0 0
278 0 ▶ warn "DEBUG: Servers defined, we're done.\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
279 0 last;
280 }
281  
282 # Grab next line of text
283 0 $t = shift(@{ $text });
284 0 ▶ warn "DEBUG: t = $t\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
285  
286 # Skip to next line if current line is blank
287 0 ▶ next if $t =~ /^$/;
Branch: 1 branch
BranchTrueFalseTotal
if $t =~ /^$/ 0 0 0
288  
289 # If we get a match for our nameserver regex pattern...
290 0 ▶ if ($t =~ /$self->{'regex_nameservers'}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /$self->{"regex_nameservers"}/) 0 0 0
291 0 ▶ warn "DEBUG: Matched $self->{'regex_nameservers'} regex pattern\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
292  
293 # HMMM??
294 0 ▶ shift @{ $text } unless ${ $text }[0];
Branch: 1 branch
BranchTrueFalseTotal
unless do { $text }->[0] 0 0 0
295  
296 0 ▶ while ($t = shift @{ $text }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t = shift @{$text;}) 0 0 0
297 0 ▶ if ($self->{'my_nameservers_noips'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'my_nameservers_noips'}) { } 0 0 0
298 0 @temp = [ $t, $self->na ];
299 0 push @s, @temp;
300 0 ▶ warn "DEBUG: Nameserver with no IP\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
301 } else {
302 0 push @s, [split /\s+/, $t];
303 0 ▶ warn "DEBUG: Nameserver with IP\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
304 }
305 }
306 0 $self->{SERVERS} = \@s;
307  
308 0 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 0 0
309 0 foreach $dns (@s) { warn "DEBUG: DNS server = $dns\n"; }
310 }
311 }
312 }
313  
314 0 ▶ warn "DEBUG: parse_nameservers() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
315 }
316  
317 # Parse out dates on when domain created, expires, and updated. Except
318 # NetSol doesn't give out when a domain was last updated. Some registrars
319 # might but that check is removed for now until script is stablized
320 # --jcm
321 # Ok, adding updated check back in, need to make sure it won't break for
322 # those registrars that don't provide the info (i.e. don't assume
323 # regex_expired exists!) --jcm, 11/16/05
324 #
325 0 ▶sub parse_domain_stats {
Subroutine parse_domain_stats: not called CC=12 SCAR=50.5
Pod undocumented
326 # Initialization
327 0 my ($self, $text) = @_;
328 0 my $t;
329  
330 0 ▶ warn "DEBUG: parse_domain_stats() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
331  
332 # As long as there's text to read...
333 0 ▶ while (@{ $text}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$text;}) 0 0 0
334 # Done if all three stats are defined
335 0 ▶ last if ($self->{RECORD_CREATED} && $self->{RECORD_UPDATED} && $self->{RECORD_EXPIRES});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RECORD_CREATED"} and $self->{"RECORD_UPDATED"} and $self->{"RECORD_EXPIRES"} 0 0 0
Condition0%0/6
$self->{"RECORD_CREATED"} and $self->{"RECORD_UPDATED"} and $self->{"RECORD_EXPIRES"}
!ll&&!rl&&r
000
$self->{"RECORD_CREATED"} and $self->{"RECORD_UPDATED"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"RECORD_CREATED"} and $self->{"RECORD_UPDATED"} and $self->{"RECORD_EXPIRES"}
$self->{"RECORD_CREATED"} $self->{"RECORD_UPDATED"} $self->{"RECORD_EXPIRES"}
Truth table0%0/4
A and B and C
A= $self->{"RECORD_CREATED"}B= $self->{"RECORD_UPDATED"}C= $self->{"RECORD_EXPIRES"}
ABCresult
0XX0
10X0
1100
1111
336  
337 # Grab next line of text, skip to next if blank
338 0 $t = shift(@{ $text });
339 0 ▶ next if $t=~ /^$/;
Branch: 1 branch
BranchTrueFalseTotal
if $t =~ /^$/ 0 0 0
340  
341 0 ▶ warn "DEBUG: t = $t\nDEBUG: RECORD_CREATED = $self->{RECORD_CREATED}\nDEBUG: RECORD_UPDATED = $self->{RECORD_UPDATED}\nDEBUG: RECORD_EXPIRES = $self->{RECORD_EXPIRES}\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
342  
343 # If we match against any of our regex patterns, store the
344 # the result in the appropriate parameter.
345 0 ▶ if ($t =~ /$self->{'regex_created'}/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($t =~ /$self->{'regex_created'}/) { } 0 0 0
elsif ($t =~ /$self->{'regex_updated'}/) { } 0 0 0
elsif ($t =~ /$self->{'regex_expires'}/) { } 0 0 0
346 0 $self->{RECORD_CREATED} = $1;
347 } elsif ($t =~ /$self->{'regex_updated'}/) {
348 0 $self->{RECORD_UPDATED} = $1;
349 } elsif ($t =~ /$self->{'regex_expires'}/) {
350 0 $self->{RECORD_EXPIRES} = $1;
351 }
352 }
353  
354 0 ▶ warn "DEBUG: parse_domain_stats() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
355 }
356  
357 # Parse out the domain name (which we already have of course, so not sure
358 # why we bother with this...) --jcm
359 0 ▶sub parse_domain_name {
Subroutine parse_domain_name: not called CC=7 SCAR=40.3
Pod undocumented
360 # Initialization
361 0 my $self = shift;
362 0 my $text = shift;
363 0 my $t;
364 0 ▶ warn "DEBUG: parse_domain_name() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
365  
366 # As long as there's text to read...
367 0 ▶ while (@{ $text}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$text;}) 0 0 0
368 # Done if the domain name has been found
369 0 ▶ last if ($self->{DOMAIN});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DOMAIN"} 0 0 0
370  
371 # Grab next line of text, skip if it's blank
372 0 $t = shift(@{ $text });
373 0 ▶ next if $t=~ /^$/;
Branch: 1 branch
BranchTrueFalseTotal
if $t =~ /^$/ 0 0 0
374  
375 # If we match our domain name regex pattern...
376 0 ▶ if ($t =~ /$self->{'regex_domain'}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /$self->{"regex_domain"}/) 0 0 0
377 # Define our domain value accordingly.
378 0 $self->{DOMAIN} = $1;
379 }
380 }
381  
382 0 ▶ warn "DEBUG: parse_domain_name() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
383 }
384  
385 # Create a new instance of this object class (Net::ParseWhois)
386 1 ▶sub new {
Subroutine new: called CC=4 SCAR=16.6
Pod undocumented
387 1 my $class = shift;
388 1 my $ref = shift;
389 0 ▶ my %hash = %{ $ref } if ($ref);
Branch: 1 branch
BranchTrueFalseTotal
if $ref 0 1 1
390 1 my $obj = bless ( \%hash, $class );
391
392 1 ▶ if (defined $obj->my_data) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj->my_data) 0 1 1
393 0 foreach my $field (@{ $obj->my_data }) {
394 0 $obj->{$field} = $obj->$field();
395 }
396 }
397  
398 1 return $obj;
399 }
400
401 # Return a value of "Not applicable".
402 0 ▶sub na {
Subroutine na: not called CC=1 SCAR=6.9
Pod undocumented
403 0 return "n/a";
404 }
405  
406 # Subroutine to follow a referral on an object
407 0 ▶sub follow_referral {
Subroutine follow_referral: not called CC=6 SCAR=37.4
Pod undocumented
408 # Initialization
409 0 my $self = shift;
410 0 ▶ warn "DEBUG: follow_referral() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
411  
412 # Try and connect to whois server
413 0 $self->{'base_server_name'} = $self->whois_server;
414 0 ▶ my $sock = $self->_connect || die "unable to open connection\n";
Condition0%0/2
$self->_connect || die("unable to open connection\n")
l!l
00
MC/DC0%0/1
$self->_connect || die("unable to open connection\n")
$self->_connect
Truth table0%0/2
A
A= $self->_connect
Aresult
11
00
415 0 my $text = $self->_send_to_sock( $sock );
416  
417 # Grab the raw whois text and store it for parsing by other routines
418 0 $self->{RAW_WHOIS_TEXT} = join("\n", @{ $text } );
419  
420 # If this was an unknown registrar...
421 0 ▶ if ($self->unknown_registrar) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->unknown_registrar) { } 0 0 0
422 # don't parse, just return $self with raw data
423 0 $self->{MATCH} = 1;
424 0 ▶ warn "DEBUG: follow_referral() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
425 0 return $self;
426 } else {
427 # Return with the parsed text (we hope)
428 0 ▶ warn "DEBUG: follow_referral() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
429 0 $self->parse_text($text);
430 }
431 }
432  
433 # Return the current whois server
434 0 ▶sub whois_server {
Subroutine whois_server: not called CC=3 SCAR=24.8
Pod undocumented
435 0 my $self = shift;
436 0 ▶ warn "DEBUG: whois_server() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
437  
438 0 return $self->{'whois_referral'};
439  
440 0 ▶ warn "DEBUG: whois_server() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
441 }
442  
443 # Dump all of the registry data returned from the whois server
444 0 ▶sub dump_text {
Subroutine dump_text: not called CC=5 SCAR=34.0
Pod undocumented
445 # Initialization
446 0 my $self = shift;
447 0 my $text = shift;
448 0 ▶ warn "DEBUG: dump_text() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
449  
450 0 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 0 0
451 0 warn "DEBUG: raw registry data:\n";
452 0 warn "DEBUG: ----------------------------------\n";
453 0 foreach (@{ $text }) { warn "DEBUG: \"$_\"\n"; }
454 0 warn "DEBUG: ----------------------------------\n";
455 0 warn "DEBUG: end registry data.\n";
456 }
457  
458 0 ▶ warn "DEBUG: dump_text() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
459 }
460  
461 # This subroutine *should* be overloaded by the particular Registrar class
462 # being used. If not, then this code here runs and program exits.
463 0 ▶sub parse_text {
Subroutine parse_text: not called CC=5 SCAR=34.0
Pod undocumented
464 # Initialization
465 0 my $self = shift;
466 0 my $text = shift;
467 0 ▶ warn "DEBUG: parse_text() running\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
468  
469 0 ▶ warn "DEBUG: \$self->parse_text NOT defined. Dumping data, and then dieing.\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
470  
471 0 foreach my $line (@{ $text }) {
472 0 print "$line\n";
473 }
474  
475 #TODO get rid of die ..
476 0 die "$self->parse_text not defined.\n";
477  
478 0 return $self;
479  
480 0 ▶ warn "DEBUG: parse_text() ending\n" if $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug 0 0 0
481 }
482  
483  
484 # TODO
485 # all of the below is silly. Via these accessor methods we should also be
486 # setting the values, rather than using UPPERCASE hash keys in $self.
487 # or these should be named get_domain, get_name, etc.
488 # right .. ? --aai 12/05/00
489  
490 0 ▶sub domain {
Subroutine domain: not called CC=2 SCAR=17.9
Pod undocumented
491 0 my $self = shift;
492 0 ▶ $self->{DOMAIN} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"DOMAIN"} or $self->na 0 0 0
493 }
494  
495 0 ▶sub name {
Subroutine name: not called CC=2 SCAR=17.9
Pod undocumented
496 0 my $self = shift;
497 0 ▶ $self->{NAME} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"NAME"} or $self->na 0 0 0
498 }
499  
500 0 ▶sub tag {
Subroutine tag: not called CC=2 SCAR=17.9
Pod undocumented
501 0 my $self = shift;
502 0 ▶ $self->{TAG} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"TAG"} or $self->na 0 0 0
503 }
504  
505 0 ▶sub address {
Subroutine address: not called CC=3 SCAR=24.8
Pod undocumented
506 0 my $self = shift;
507 0 ▶ my $addr = $self->{ADDRESS} || [ $self->na ];
Condition0%0/2
$self->{'ADDRESS'} || [$self->na]
l!l
00
MC/DC0%0/1
$self->{'ADDRESS'} || [$self->na]
$self->{'ADDRESS'}
Truth table0%0/2
A
A= $self->{'ADDRESS'}
Aresult
11
00
508 0 ▶ wantarray ? @ $addr : join "\n", @$addr;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
509 }
510  
511 0 ▶sub country {
Subroutine country: not called CC=2 SCAR=17.9
Pod undocumented
512 0 my $self = shift;
513 0 ▶ $self->{COUNTRY} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"COUNTRY"} or $self->na 0 0 0
514 }
515  
516 0 ▶sub contacts {
Subroutine contacts: not called CC=2 SCAR=17.9
Pod undocumented
517 0 my $self = shift;
518 0 ▶ $self->{CONTACTS} || { $self->na };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"CONTACTS"} or {$self->na} 0 0 0
519 }
520  
521 0 ▶sub registrar {
Subroutine registrar: not called CC=2 SCAR=17.9
Pod undocumented
522 0 my $self = shift;
523 0 ▶ return $self->{'registrar_tag'} || $self->na;
Condition0%0/3
$self->{'registrar_tag'} || $self->na
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'registrar_tag'} || $self->na
$self->{'registrar_tag'} $self->na
Truth table0%0/3
A || B
A= $self->{'registrar_tag'}B= $self->na
ABresult
1X1
011
000
524 }
525  
526 0 ▶sub servers {
Subroutine servers: not called CC=2 SCAR=17.9
Pod undocumented
527 0 my $self = shift;
528 0 ▶ if (!$self->{SERVERS}) { # TODO: yuck ..
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"SERVERS"}) 0 0 0
529 0 my (@tmp, @ret);
530 0 push(@tmp, $self->na);
531 0 push(@tmp, $self->na);
532 0 my $ref = \@tmp;
533 0 push(@ret, $ref);
534 0 return \@ret;
535 }
536  
537 0 return $self->{SERVERS};
538 }
539  
540 0 ▶sub record_created {
Subroutine record_created: not called CC=2 SCAR=17.9
Pod undocumented
541 0 my $self = shift;
542 0 ▶ $self->{RECORD_CREATED} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"RECORD_CREATED"} or $self->na 0 0 0
543 }
544  
545 0 ▶sub record_updated {
Subroutine record_updated: not called CC=2 SCAR=17.9
Pod undocumented
546 0 my $self = shift;
547 0 ▶ $self->{RECORD_UPDATED} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"RECORD_UPDATED"} or $self->na 0 0 0
548 }
549  
550 0 ▶sub record_expires {
Subroutine record_expires: not called CC=2 SCAR=17.9
Pod undocumented
551 0 my $self = shift;
552 0 ▶ $self->{RECORD_EXPIRES} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"RECORD_EXPIRES"} or $self->na 0 0 0
553 }
554  
555 0 ▶sub raw_whois_text {
Subroutine raw_whois_text: not called CC=2 SCAR=17.9
Pod undocumented
556 0 my $self = shift;
557 0 ▶ $self->{RAW_WHOIS_TEXT} || $self->na;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"RAW_WHOIS_TEXT"} or $self->na 0 0 0
558 }
559  
560 0 ▶sub unknown_registrar {
Subroutine unknown_registrar: not called CC=2 SCAR=17.9
Pod undocumented
561 0 my $self = shift;
562 0 ▶ $self->{UNKNOWN_REGISTRAR} || '0';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"UNKNOWN_REGISTRAR"} or 0 0 0 0
563 }
564  
565 1 1;
« ParseWhois/Domain.pm ↑ Summary ParseWhois/Domain/Registrar/BulkRegister.pm »