DRI/Protocol/Whois/Domain/WS.pm

filter: Statementstmt 16.4% 13 / 79 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 8 totaltotal 10.5% 17 / 161 CC 24 SCAR 35.8
CC
24
Cov
10%
parse_registrar
90.0
parse_contacts
30.0
parse_ns
30.0
CRAP 35.9
« DRI/Protocol/EPP/Extensions/IT/Contact.pm ↑ Summary DRI/Protocol/RRP/Core/Session.pm »
1 ## Domain Registry Interface, Whois commands for .WS (RFC3912)
2 ##
3 ## Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::Whois::Domain::WS;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =pod
24  
25 =head1 NAME
26  
27 Net::DRI::Protocol::Whois::Domain::WS - .WS Whois commands (RFC3912) for Net::DRI
28  
29 =head1 DESCRIPTION
30  
31 Please see the README file for details.
32  
33 =head1 SUPPORT
34  
35 For now, support questions should be sent to:
36  
37 E<lt>netdri@dotandco.comE<gt>
38  
39 Please also see the SUPPORT file in the distribution.
40  
41 =head1 SEE ALSO
42  
43 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
44  
45 =head1 AUTHOR
46  
47 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
48  
49 =head1 COPYRIGHT
50  
51 Copyright (c) 2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>.
52 All rights reserved.
53  
54 This program is free software; you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
56 the Free Software Foundation; either version 2 of the License, or
57 (at your option) any later version.
58  
59 See the LICENSE file that comes with this distribution for more details.
60  
61 =cut
62  
63 ####################################################################################################
64  
65 sub register_commands
66 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
67 0 my ($class,$version)=@_;
68 0 return { 'domain' => { info => [ \&info, \&info_parse ] } };
69 }
70  
71 sub info
72 0 ▶{
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my ($po,$domain,$rd)=@_;
74 0 my $mes=$po->message();
75 0 ▶ Net::DRI::Exception->die(1,'protocol/whois',10,'Invalid domain name: '.$domain) unless Net::DRI::Util::is_hostname($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($domain) 0 0 0
76 0 $mes->command('domain '.lc($domain));
77 0 return;
78 }
79  
80 sub info_parse
81 0 ▶{
Subroutine info_parse: not called CC=4 SCAR=30.0
Pod undocumented
82 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
83 0 my $mes=$po->message();
84 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
85  
86 0 my $rr=$mes->response();
87 0 my $rd=$mes->response_raw();
88 0 my ($domain,$exist)=parse_domain($po,$rr,$rd,$rinfo);
89 0 ▶ $domain=lc($oname) unless defined($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $domain 0 0 0
90 0 $rinfo->{domain}->{$domain}->{exist}=$exist;
91 0 $rinfo->{domain}->{$domain}->{action}='info';
92  
93 0 ▶ return unless $exist;
Branch: 1 branch
BranchTrueFalseTotal
unless $exist 0 0 0
94  
95 0 parse_registrar($po,$domain,$rr,$rinfo);
96 0 parse_contacts($po,$domain,$rr,$rinfo);
97 0 parse_dates($po,$domain,$rd,$rinfo);
98 0 parse_ns($po,$domain,$rd,$rinfo);
99 0 return;
100 }
101  
102 sub parse_domain
103 0 ▶{
Subroutine parse_domain: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my ($po,$rr,$rd,$rinfo)=@_;
105 0 my ($dom,$e);
106 0 ▶ if (exists($rr->{'Domain Name'}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rr->{'Domain Name'}) { } 0 0 0
107 {
108 0 $e=1;
109 0 $dom=lc($rr->{'Domain Name'}->[0]);
110 } else ## may also be invalid domain name or reserved domain name
111 {
112 0 $e=0;
113 }
114 0 return ($dom,$e);
115 }
116  
117 ## Does not seem to be always there ! (present for whatever.ws, not present for website.ws)
118 sub parse_registrar
119 0 ▶{
Subroutine parse_registrar: not called CC=9 SCAR=45.0
Pod undocumented
120 0 my ($po,$domain,$rr,$rinfo)=@_;
121 0 ▶ $rinfo->{domain}->{$domain}->{clName}=$rr->{'Registrar Name'}->[0] if (exists($rr->{'Registrar Name'}) && $rr->{'Registrar Name'}->[0]) ;
Branch: 1 branch
BranchTrueFalseTotal
if exists $rr->{"Registrar Name"} and $rr->{"Registrar Name"}[0] 0 0 0
Condition0%0/3
exists $rr->{"Registrar Name"} and $rr->{"Registrar Name"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Registrar Name"} and $rr->{"Registrar Name"}[0]
exists $rr->{"Registrar Name"} $rr->{"Registrar Name"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Name"}B= $rr->{"Registrar Name"}[0]
ABresult
0X0
100
111
122 0 ▶ $rinfo->{domain}->{$domain}->{clEmail}=$rr->{'Registrar Email'}->[0] if (exists($rr->{'Registrar Email'}) && $rr->{'Registrar Email'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $rr->{"Registrar Email"} and $rr->{"Registrar Email"}[0] 0 0 0
Condition0%0/3
exists $rr->{"Registrar Email"} and $rr->{"Registrar Email"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Registrar Email"} and $rr->{"Registrar Email"}[0]
exists $rr->{"Registrar Email"} $rr->{"Registrar Email"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Email"}B= $rr->{"Registrar Email"}[0]
ABresult
0X0
100
111
123 0 ▶ $rinfo->{domain}->{$domain}->{clVoice}=$rr->{'Registrar Telephone'}->[0] if (exists($rr->{'Registrar Telephone'}) && $rr->{'Registrar Telephone'}->[0]);
Branch: 1 branch
BranchTrueFalseTotal
if exists $rr->{"Registrar Telephone"} and $rr->{"Registrar Telephone"}[0] 0 0 0
Condition0%0/3
exists $rr->{"Registrar Telephone"} and $rr->{"Registrar Telephone"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Registrar Telephone"} and $rr->{"Registrar Telephone"}[0]
exists $rr->{"Registrar Telephone"} $rr->{"Registrar Telephone"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Telephone"}B= $rr->{"Registrar Telephone"}[0]
ABresult
0X0
100
111
124 0 ▶ $rinfo->{domain}->{$domain}->{clWhois}=$rr->{'Registrar Whois'}->[0] if (exists($rr->{'Registrar Whois'}) &&$rr->{'Registrar Whois'}->[0]) ;
Branch: 1 branch
BranchTrueFalseTotal
if exists $rr->{"Registrar Whois"} and $rr->{"Registrar Whois"}[0] 0 0 0
Condition0%0/3
exists $rr->{"Registrar Whois"} and $rr->{"Registrar Whois"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Registrar Whois"} and $rr->{"Registrar Whois"}[0]
exists $rr->{"Registrar Whois"} $rr->{"Registrar Whois"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrar Whois"}B= $rr->{"Registrar Whois"}[0]
ABresult
0X0
100
111
125 0 return;
126 }
127  
128 ## Does not seem to be always there (see previous example, opposite case)
129 sub parse_contacts
130 0 ▶{
Subroutine parse_contacts: not called CC=5 SCAR=34.0
Pod undocumented
131 0 my ($po,$domain,$rr,$rinfo)=@_;
132 0 my $cs=$po->create_local_object('contactset');
133  
134 0 ▶ if (exists($rr->{'Registrant Name'}) && $rr->{'Registrant Name'}->[0])
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rr->{"Registrant Name"} and $rr->{"Registrant Name"}[0]) 0 0 0
Condition0%0/3
exists $rr->{"Registrant Name"} and $rr->{"Registrant Name"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Registrant Name"} and $rr->{"Registrant Name"}[0]
exists $rr->{"Registrant Name"} $rr->{"Registrant Name"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Registrant Name"}B= $rr->{"Registrant Name"}[0]
ABresult
0X0
100
111
135 {
136 0 my $c=$po->create_local_object('contact');
137 0 $c->name($rr->{'Registrant Name'}->[0]);
138 0 $c->email($rr->{'Registrant Email'}->[0]);
139 0 $cs->add($c,'registrant');
140 }
141 0 ▶ if (exists($rr->{'Administrative Contact Email'}) && $rr->{'Administrative Contact Email'}->[0])
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rr->{"Administrative Contact Email"} and $rr->{"Administrative Contact Email"}[0]) 0 0 0
Condition0%0/3
exists $rr->{"Administrative Contact Email"} and $rr->{"Administrative Contact Email"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rr->{"Administrative Contact Email"} and $rr->{"Administrative Contact Email"}[0]
exists $rr->{"Administrative Contact Email"} $rr->{"Administrative Contact Email"}[0]
Truth table0%0/3
A and B
A= exists $rr->{"Administrative Contact Email"}B= $rr->{"Administrative Contact Email"}[0]
ABresult
0X0
100
111
142 {
143 0 my $c=$po->create_local_object('contact');
144 0 $c->email($rr->{'Administrative Contact Email'}->[0]);
145 0 $c->voice($rr->{'Administrative Contact Telephone'}->[0]);
146 0 $cs->add($c,'admin');
147 }
148 0 $rinfo->{domain}->{$domain}->{contact}=$cs;
149 0 return;
150 }
151  
152 sub parse_dates
153 0 ▶{
Subroutine parse_dates: not called CC=3 SCAR=24.8
Pod undocumented
154 0 my ($po,$domain,$rd,$rinfo)=@_;
155 0 my $strp=$po->build_strptime_parser(pattern => '%Y-%m-%d %T', time_zone => 'America/Los_Angeles');
156 0 my @tmp;
157 0 @tmp=grep { m/Domain created on/ } @$rd;
158 0 ▶ $rinfo->{domain}->{$domain}->{crDate}=$strp->parse_datetime(($tmp[0]=~m/^\s+Domain created on (\S+ \S+)\s*$/)[0]) if @tmp;
Branch: 1 branch
BranchTrueFalseTotal
if @tmp 0 0 0
159 0 @tmp=grep { m/Domain last updated on/ } @$rd;
160 0 ▶ $rinfo->{domain}->{$domain}->{upDate}=$strp->parse_datetime(($tmp[0]=~m/^\s+Domain last updated on (\S+ \S+)\s*$/)[0]) if @tmp;
Branch: 1 branch
BranchTrueFalseTotal
if @tmp 0 0 0
161 0 return;
162 }
163  
164 sub parse_ns
165 0 ▶{
Subroutine parse_ns: not called CC=5 SCAR=34.0
Pod undocumented
166 0 my ($po,$domain,$rd,$rinfo)=@_;
167 0 my @ns;
168 0 foreach my $l (@$rd)
169 {
170 0 ▶ next unless (($l=~m/^\s+ Current Nameservers:/)..1);
Branch: 1 branch
BranchTrueFalseTotal
unless $l =~ /^\s+ Current Nameservers:/ .. 1 0 0 0
171 0 ▶ push @ns,$1 if ($l=~m/^\s*(\S+[^\.])\.?\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^\s*(\S+[^\.])\.?\s*$/ 0 0 0
172 }
173 0 ▶ $rinfo->{domain}->{$domain}->{ns}=$po->create_local_object('hosts')->set(@ns) if @ns;
Branch: 1 branch
BranchTrueFalseTotal
if @ns 0 0 0
174 0 return;
175 }
176  
177 ####################################################################################################
178 1 1;
« DRI/Protocol/EPP/Extensions/IT/Contact.pm ↑ Summary DRI/Protocol/RRP/Core/Session.pm »