DRI/Protocol/Whois/Domain/AT.pm

filter: Statementstmt 14.4% 13 / 90 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 10.6% 17 / 160 CC 26 SCAR 48.8
CC
26
Cov
9%
parse_contacts
272.0
parse_ns
42.0
info_parse
20.0
CRAP 131.0
« DRI/Data/Contact/SIDN.pm ↑ Summary DRI/Protocol/EPP/Extensions/KeyRelay.pm »
1 ## Domain Registry Interface, Whois commands for .AT (RFC3912)
2 ##
3 ## Copyright (c) 2008,2009,2013,2014 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::AT;
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::AT - .AT 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,2014 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(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_ns($po,$domain,$rr,$rinfo);
96 0 parse_dates($po,$domain,$rr,$rinfo);
97 0 parse_contacts($po,$domain,$rr,$rd,$rinfo);
98 0 return;
99 }
100  
101 sub parse_domain
102 0 ▶{
Subroutine parse_domain: not called CC=2 SCAR=17.9
Pod undocumented
103 0 my ($po,$rr,$rd,$rinfo)=@_;
104 0 my ($dom,$e);
105 0 ▶ if (exists($rr->{'domain'}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rr->{'domain'}) { } 0 0 0
106 {
107 0 $e=1;
108 0 $dom=lc($rr->{'domain'}->[0]);
109 } else
110 {
111 0 $e=0;
112 }
113 0 return ($dom,$e);
114 }
115  
116 sub parse_ns
117 0 ▶{
Subroutine parse_ns: not called CC=6 SCAR=37.4
Pod undocumented
118 0 my ($po,$domain,$rr,$rinfo)=@_;
119 0 ▶ return unless exists($rr->{'nserver'});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{"nserver"} 0 0 0
120  
121 ## I do not know how multiple IPs for one host are handled, we do the very crude way for now
122 0 my $h=$po->create_local_object('hosts');
123 0 ▶ my @n=grep { defined($_) && $_ } @{$rr->{'nserver'}};
Condition0%0/3
defined $_ && $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && $_
defined $_ $_
Truth table0%0/3
A && B
A= defined $_B= $_
ABresult
0X0
100
111
124 0 ▶ my @i=grep { defined($_) && $_ } @{$rr->{'remarks'}};
Condition0%0/3
defined $_ && $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && $_
defined $_ $_
Truth table0%0/3
A && B
A= defined $_B= $_
ABresult
0X0
100
111
125 0 ▶ while(@n)
Branch: 1 branch
BranchTrueFalseTotal
if (@n) 0 0 0
126 {
127 0 $h->add(shift(@n),[shift(@i)]);
128 }
129 0 ▶ $rinfo->{domain}->{$domain}->{ns}=$h unless $h->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->is_empty 0 0 0
130 0 return;
131 }
132  
133 sub parse_dates
134 0 ▶{
Subroutine parse_dates: not called CC=1 SCAR=6.9
Pod undocumented
135 0 my ($po,$domain,$rr,$rinfo)=@_;
136 0 my $strp=$po->build_strptime_parser(pattern => '%Y%m%d %T', time_zone => 'Europe/Vienna');
137 0 $rinfo->{domain}->{$domain}->{upDate}=$strp->parse_datetime($rr->{'changed'}->[0]);
138 0 return;
139 }
140  
141 sub parse_contacts
142 0 ▶{
Subroutine parse_contacts: not called CC=16 SCAR=56.1
Pod undocumented
143 0 my ($po,$domain,$rr,$rd,$rinfo)=@_;
144 0 my $cs=$po->create_local_object('contactset');
145 0 my %t=('registrant' => 'registrant', 'admin-c' => 'admin', 'tech-c' => 'tech');
146 0 my %tmp;
147  
148 ## First pass, only the IDs
149 0 foreach my $t (sort { $a cmp $b } keys %t)
150 {
151 0 my $c=$po->create_local_object('contact');
152 0 my $id=$rr->{$t}->[0];
153 0 $tmp{$id}=$c;
154 0 $c->srid($id);
155 0 $cs->add($c,$t{$t});
156 }
157  
158 ## Now all details
159 0 my ($id,@s);
160 0 foreach my $l (reverse grep { (($_=~m/^personname:/)..($_=~m/^\s*$/)) } @$rd)
161 {
162 0 ▶ next if ($l=~m/^(?:source|changed):/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^(?:source|changed):/ 0 0 0
163 0 ▶ $id=$1 if ($l=~m/^nic-hdl:\s+(\S+)\s*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /^nic-hdl:\s+(\S+)\s*$/ 0 0 0
164 0 ▶ if ($l=~m/^e-mail:\s+(\S+)\s*$/)
Branch: 9 branches
BranchTrueFalseTotal
if ($l =~ /^e-mail:\s+(\S+)\s*$/) { } 0 0 0
elsif ($l =~ /^fax-no:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^phone:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^country:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^city:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^postal code:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^street address:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^organization:\s+(\S.+\S)\s*$/) { } 0 0 0
elsif ($l =~ /^personname:\s+(\S.+\S)\s*$/) { } 0 0 0
165 {
166 0 $tmp{$id}->email($1);
167 } elsif ($l=~m/^fax-no:\s+(\S.+\S)\s*$/)
168 {
169 0 $tmp{$id}->fax($1);
170 } elsif ($l=~m/^phone:\s+(\S.+\S)\s*$/)
171 {
172 0 $tmp{$id}->voice($1);
173 } elsif ($l=~m/^country:\s+(\S.+\S)\s*$/)
174 {
175 0 $tmp{$id}->cc($1);
176 } elsif ($l=~m/^city:\s+(\S.+\S)\s*$/)
177 {
178 0 $tmp{$id}->city($1);
179 } elsif ($l=~m/^postal code:\s+(\S.+\S)\s*$/)
180 {
181 0 $tmp{$id}->pc($1);
182 } elsif ($l=~m/^street address:\s+(\S.+\S)\s*$/)
183 {
184 0 push @s,$1;
185 } elsif ($l=~m/^organization:\s+(\S.+\S)\s*$/)
186 {
187 0 $tmp{$id}->org($1);
188 0 ▶ $tmp{$id}->street([reverse(@s)]) if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
189 0 @s=();
190 } elsif ($l=~m/^personname:\s+(\S.+\S)\s*$/)
191 {
192 0 $tmp{$id}->name($1);
193 0 ▶ $tmp{$id}->street([reverse(@s)]) if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
194 0 @s=();
195 }
196 }
197 0 $rinfo->{domain}->{$domain}->{contact}=$cs;
198 0 return;
199 }
200  
201 ####################################################################################################
202 1 1;
« DRI/Data/Contact/SIDN.pm ↑ Summary DRI/Protocol/EPP/Extensions/KeyRelay.pm »