EPP/DrsUa.pm

filter: Statementstmt 10.7% 13 / 121 Branchbran 0.0% 0 / 44 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 26.6% 4 / 15 Podpod 100% 10 / 10 totaltotal 12.8% 27 / 211 SCAR 69.7
CC
36
Cov
7%
make_request
132.0
req_poll_rdata
110.0
update_domain_add_nss
30.0
CRAP 1068.3
« EPP/Verisign.pm ↑ Summary EPP/TCI.pm »
1 package IO::EPP::DrsUa;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 IO::EPP::DrsUa
8  
9 =head1 SYNOPSIS
10  
11 use IO::EPP::DrsUa;
12  
13 # Parameters for IO::Socket::SSL
14 my %sock_params = (
15 PeerHost => 'epp.uadns.com',
16 PeerPort => 700,
17 # without certificate
18 Timeout => 30,
19 );
20  
21 # Create object, get greeting and call login()
22 my $conn = IO::EPP::DrsUa->new( {
23 user => 'login',
24 pass => 'xxxx',
25 sock_params => \%sock_params,
26 test_mode => 0, # real connect
27 } );
28  
29 # Check domain
30 my ( $answ, $code, $msg ) = $conn->check_domains( { domains => [ 'qqq.com.ua', 'aaa.biz.ua' ] } );
31  
32 # Call logout() and destroy object
33 undef $conn;
34  
35 =head1 DESCRIPTION
36  
37 Module for work with nic.ua/drs.ua domains
38  
39 Drs.ua is a registry for biz.ua, co.ua, pp.ua and reseller for other .ua tlds
40  
41 drs.ua uses deprecated epp version 0.5 -- it uses hostAttr instead of hostObj
42  
43 Features:
44  
45 =over 4
46  
47 =item *
48  
49 special PP format
50  
51 =item *
52  
53 the contact id must be suffixed on "-cunic"
54  
55 =item *
56  
57 need full name in contact:update
58  
59 =item *
60  
61 to change the email address, you need to update the contact, not change the contact id
62  
63 =item *
64  
65 additional extensions with login should be passed as objURI, not extURI
66  
67 =item *
68  
69 contacts have only type loc
70  
71 =item *
72  
73 no commands host:check, host:create, host:update (consequence of hostAttr)
74  
75 =item *
76  
77 cannot use punycode in the email to the left of @
78  
79 =item *
80  
81 in contacts for an individual, the company field must be empty
82  
83 =item *
84  
85 domains in the zone pp.ua you can not delete, you can only not confirm the sms about registration or renewal so that they themselves are deleted
86  
87 =item *
88  
89 the disclose flag only works for biz.ua, co.ua
90  
91 For pp.ua you can't hide contacts
92  
93 In other tlds Privacy Protection must be performed on the client side
94  
95 =item *
96  
97 epp poll sends only the transaction number and also the result in the form of ok or fail, without the domain name or contact id
98  
99 =back
100  
101 Documentation:
102 L<http://drs.ua/rus/policy.html>,
103 L<http://tools.ietf.org/html/rfc3730>
104  
105 =cut
106  
107 1 ▶use IO::EPP::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 1 ▶use parent qw( IO::EPP::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
109  
110 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
112  
113  
114 sub make_request {
115 0 ▶ my ( $action, $params ) = @_;
Subroutine make_request: not called CC=11 SCAR=48.8
Pod documented
116  
117 0 my ( $self, $code, $msg, $answ );
118  
119 0 ▶ unless ( $params->{conn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'conn'}) { } 0 0 0
120 0 ▶ $params->{sock_params}{PeerHost} ||= 'epp.uadns.com';
Condition0%0/2
$params->{"sock_params"}{"PeerHost"} ||= "epp.uadns.com"
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerHost"} ||= "epp.uadns.com"
$params->{"sock_params"}{"PeerHost"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerHost"}
Aresult
11
00
121 0 ▶ $params->{sock_params}{PeerPort} ||= 700;
Condition0%0/2
$params->{"sock_params"}{"PeerPort"} ||= 700
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerPort"} ||= 700
$params->{"sock_params"}{"PeerPort"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerPort"}
Aresult
11
00
122  
123 0 ( $self, $code, $msg ) = __PACKAGE__->new( $params );
124  
125 0 ▶ unless ( $code and $code == 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($code and $code == 1000) 0 0 0
Condition0%0/3
$code and $code == 1000
!ll&&!rl&&r
000
MC/DC0%0/2
$code and $code == 1000
$code $code == 1000
Truth table0%0/3
A and B
A= $codeB= $code == 1000
ABresult
0X0
100
111
126 0 goto END_MR;
127 }
128 }
129 else {
130 0 $self = $params->{conn};
131 }
132  
133  
134 0 $self->{critical_error} = '';
135  
136 0 ▶ if ( $self->can( $action ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($action)) { } 0 0 0
137 0 ( $answ, $code, $msg ) = $self->$action( $params );
138 }
139 else {
140 0 $msg = "undefined command <$action>, request cancelled";
141 0 $code = 0;
142 }
143  
144  
145 END_MR:
146  
147 0 ▶ $msg .= '; ' . $self->{critical_error} if $self->{critical_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"critical_error"} 0 0 0
148  
149 0 my $full_answ = "code: $code\nmsg: $msg";
150  
151 0 ▶ $answ = {} unless $answ && ref $answ;
Branch: 1 branch
BranchTrueFalseTotal
unless $answ and ref $answ 0 0 0
Condition0%0/3
$answ and ref $answ
!ll&&!rl&&r
000
MC/DC0%0/2
$answ and ref $answ
$answ ref $answ
Truth table0%0/3
A and B
A= $answB= ref $answ
ABresult
0X0
100
111
152  
153 0 $answ->{code} = $code;
154 0 $answ->{msg} = $msg;
155  
156 0 ▶ return wantarray ? ( $answ, $full_answ, $self ) : $answ;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
157 }
158  
159 =head1 METHODS
160  
161 Further overlap functions where the provider has features
162  
163 =cut
164  
165 sub login {
166 0 ▶ my ( $self, $pw ) = @_;
Subroutine login: not called CC=1 SCAR=6.9
Pod documented
167  
168 # wihout urn:ietf:params:xml:ns:host
169 0 my $svcs = '
170 <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
171 <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>';
172  
173 0 my $extension = '
174 <objURI>http://drs.ua/epp/drs-1.0</objURI>'; # objURI !!! not extURI !!!
175  
176 0 return $self->SUPER::login( $pw, $svcs, $extension );
177 }
178  
179  
180 sub _prepare_contact {
181 0 ▶ my ( $params ) = @_;
Subroutine _prepare_contact: not called CC=4 SCAR=30.0
182  
183 # int only: code: 2400, msg: Only 'loc' type of postal info is supported
184 # int + loc: code: 2400, msg: Multiple postal info not supported
185 0 ▶ unless ( $$params{'loc'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->{"loc"}) 0 0 0
186 0 foreach my $f ( 'name','first_name','last_name','company','addr','city','state','postcode','country_code' ) {
187 0 ▶ $$params{'loc'}{$f} = delete $$params{$f} if defined $$params{$f};
Branch: 1 branch
BranchTrueFalseTotal
if defined $params->{$f} 0 0 0
188 }
189 }
190 }
191  
192 =head1 create_contact
193  
194 It has many features, see the description of the module above
195  
196 =cut
197  
198 sub create_contact {
199 0 ▶ my ( $self, $params ) = @_;
Subroutine create_contact: not called CC=2 SCAR=17.9
Pod documented
200  
201 0 _prepare_contact( $params );
202  
203 0 ▶ my $visible = $$params{pp_flag} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$params->{'pp_flag'} ? : 0 0 0
204  
205 # This format is feature drs, but for biz.ua, co.ua only
206 0 $params->{pp_ext} = '
207 <contact:disclose flag="'.$visible.'">
208 <contact:name type="loc"/>
209 <contact:org type="loc"/>
210 <contact:addr type="loc"/>
211 <contact:voice/>
212 <contact:fax/>
213 <contact:email/>
214 </contact:disclose>';
215  
216 0 return $self->SUPER::create_contact( $params );
217 }
218  
219 =head1 update_contact
220  
221 It has many features, see the description of the module above
222  
223 =cut
224  
225 sub update_contact {
226 0 ▶ my ( $self, $params ) = @_;
Subroutine update_contact: not called CC=2 SCAR=17.9
Pod documented
227  
228 0 _prepare_contact( $params );
229  
230 0 $params->{chg}{need_name} = 1;
231  
232 0 ▶ my $visible = $$params{pp_flag} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$params->{'pp_flag'} ? : 0 0 0
233  
234 0 $params->{pp_ext} = '
235 <contact:disclose flag="'.$visible.'">
236 <contact:name type="loc"/>
237 <contact:org type="loc"/>
238 <contact:addr type="loc"/>
239 <contact:voice/>
240 <contact:fax/>
241 <contact:email/>
242 </contact:disclose>';
243  
244 0 return $self->SUPER::update_contact( $params );
245 }
246  
247  
248 sub create_domain_nss {
249 0 ▶ my ( $self, $params ) = @_;
Subroutine create_domain_nss: not called CC=3 SCAR=24.8
Pod documented
250  
251 0 my $nss = '';
252  
253 # Old EPP version, sbut it was resolved in https://tools.ietf.org/html/rfc3731
254 0 foreach my $ns ( @{$params->{nss}} ) {
255 0 $nss .= " <domain:hostAttr>\n <domain:hostName>$ns</domain:hostName>\n </domain:hostAttr>\n";
256 }
257  
258 0 ▶ $nss = "\n <domain:ns>\n$nss </domain:ns>" if $nss;
Branch: 1 branch
BranchTrueFalseTotal
if $nss 0 0 0
259  
260 0 return $nss;
261 }
262  
263  
264 sub create_domain {
265 0 ▶ my ( $self, $params ) = @_;
Subroutine create_domain: not called CC=2 SCAR=17.9
Pod documented
266  
267 0 ▶ $params->{authinfo} ||= IO::EPP::Base::gen_pw( 16 );
Condition0%0/3
$params->{"authinfo"} ||= IO::EPP::Base::gen_pw(16)
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"authinfo"} ||= IO::EPP::Base::gen_pw(16)
$params->{"authinfo"} IO::EPP::Base::gen_pw(16)
Truth table0%0/3
A ||= B
A= $params->{"authinfo"}B= IO::EPP::Base::gen_pw(16)
ABresult
1X1
011
000
268  
269 0 return $self->SUPER::create_domain( $params );
270 }
271  
272  
273 sub update_domain_add_nss {
274 0 ▶ my ( $self, $params ) = @_;
Subroutine update_domain_add_nss: not called CC=5 SCAR=34.0
Pod documented
275  
276 0 my $add = " <domain:ns>\n";
277  
278 # Old EPP version, see in https://tools.ietf.org/html/rfc3731
279 0 foreach my $ns ( @{$$params{add}{nss}} ) {
280 0 $add .= " <domain:hostAttr>\n <domain:hostName>$$ns{ns}</domain:hostName>\n";
281 0 ▶ if ( $ns->{ips} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns->{"ips"}) 0 0 0
282 0 foreach my $ip ( @{$ns->{ips}} ) {
283 0 ▶ if ( $ip =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { } 0 0 0
284 0 $add .= " <domain:hostAddr ip=\"v4\">$ip</domain:hostAddr>\n";
285 }
286 else {
287 0 $add .= " <domain:hostAddr ip=\"v6\">$ip</domain:hostAddr>\n";
288 }
289 }
290 }
291  
292 0 $add .= " </domain:hostAttr>\n";
293 }
294  
295 0 $add .= " </domain:ns>\n";
296  
297 0 return $add;
298 }
299  
300  
301 sub update_domain_rem_nss {
302 0 ▶ my ( $self, $params ) = @_;
Subroutine update_domain_rem_nss: not called CC=5 SCAR=34.0
Pod documented
303  
304 0 my $rem = " <domain:ns>\n";
305  
306 # Old EPP version, see in https://tools.ietf.org/html/rfc3731
307 0 foreach my $ns ( @{$$params{rem}{nss}} ) {
308 0 $rem .= " <domain:hostAttr>\n <domain:hostName>$$ns{ns}</domain:hostName>\n";
309  
310 0 ▶ if ( $ns->{ips} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns->{"ips"}) 0 0 0
311 0 foreach my $ip ( @{$ns->{ips}} ) {
312 0 ▶ if ( $ip =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { } 0 0 0
313 0 $rem .= " <domain:hostAddr ip=\"v4\">$ip</domain:hostAddr>\n";
314 }
315 else {
316 0 $rem .= " <domain:hostAddr ip=\"v6\">$ip</domain:hostAddr>\n";
317 }
318 }
319 }
320  
321 0 $rem .= " </domain:hostAttr>\n";
322 }
323  
324 0 $rem .= " </domain:ns>\n";
325  
326 0 return $rem;
327 }
328  
329  
330 sub update_domain {
331 0 ▶ my ( $self, $params ) = @_;
Subroutine update_domain: not called CC=1 SCAR=6.9
Pod documented
332  
333 0 $params->{nss_as_attr} = 1;
334  
335 0 return $self->SUPER::update_domain( $params );
336 }
337  
338 =head1 req_poll
339  
340 It has many features, see the description of the module above
341  
342 =cut
343  
344 sub req_poll_rdata {
345 0 ▶ my ( $self, $rdata, undef ) = @_;
Subroutine req_poll_rdata: not called CC=10 SCAR=47.0
Pod documented
346  
347 0 my %info;
348  
349 0 ▶ if ( $rdata =~ /^<domain:trnData/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($rdata =~ /^<domain:trnData/) { } 0 0 0
elsif ($rdata =~ /^<domain:panData/) { } 0 0 0
elsif ($rdata =~ /^<drs:notify/) { } 0 0 0
350 # TRANSFER_PENDING, TRANSFER_CLIENT_APPROVED, TRANSFER_SERVER_APPROVED
351 0 $info{transfer} = {};
352 0 ( $info{transfer}{dname} ) = $rdata =~ /<domain:name>([^<>]+)<\/domain:name>/;
353 0 ( $info{transfer}{status} ) = $rdata =~ /<domain:trStatus>([^<>]+)<\/domain:trStatus>/;
354  
355 0 my %id = %IO::EPP::Base::id;
356 0 foreach my $k ( keys %id ) {
357 0 ▶ if ( $rdata =~ /<domain:$k>([^<>]+)<\/domain:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<domain:$k>([^<>]+)</domain:$k>]) 0 0 0
358 0 $info{transfer}{$id{$k}} = $1;
359 }
360 }
361 #( $info{transfer}{from} ) = $rdata =~ /<domain:acID>([^<>]+)<\/domain:acID>/;
362 #( $info{transfer}{to} ) = $rdata =~ /<domain:reID>([^<>]+)<\/domain:reID>/;
363 0 my %dt = %IO::EPP::Base::dt;
364 0 foreach my $k ( keys %dt ) {
365 0 ▶ if ( $rdata =~ /<domain:$k>([^<>]+)<\/domain:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<domain:$k>([^<>]+)</domain:$k>]) 0 0 0
366 0 $info{transfer}{$dt{$k}} = IO::EPP::Base::cldate( $1 );
367 }
368 }
369 }
370 elsif ( $rdata =~ /^<domain:panData/ ) {
371 # Pending action completed with error.
372 # Pending action completed successfully.
373 0 $info{upd_del} = {};
374 0 ( $info{upd_del}{result}, $info{upd_del}{dname} ) = $rdata =~ /<domain:name paResult="([^"]+)">([^<>]+)<\/domain:name>/;
375  
376 0 ▶ if ( $rdata =~ /<domain:paTRID>(.+)<\/domain:paTRID>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<domain:paTRID>(.+)</domain:paTRID>]) 0 0 0
377 0 my $trids = $1;
378 0 ( $info{upd_del}{cltrid} ) = $trids =~ /<clTRID>([^<>]+)<\/clTRID>/;
379 0 ( $info{upd_del}{svtrid} ) = $trids =~ /<svTRID>([^<>]+)<\/svTRID>/;
380 }
381  
382 0 ▶ if ( $rdata =~ /<domain:paDate>([^<>]+)<\/domain:paDate>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<domain:paDate>([^<>]+)</domain:paDate>]) 0 0 0
383 0 $info{upd_del}{date} = IO::EPP::Base::cldate( $1 );
384 }
385 }
386 elsif ( $rdata =~ /^<drs:notify/ ) {
387 # drs feature
388 0 $info{notify} = {};
389 0 ( $info{notify}{type} ) = $rdata =~ /<drs:type>([^<>]+)<\/drs:type>/; # command
390 0 ( $info{notify}{object} ) = $rdata =~ /<drs:object>([^<>]+)<\/drs:object>/; # domain
391 0 ( $info{notify}{message} ) = $rdata =~ /<drs:message>([^<>]+)<\/drs:message>/; #
392 }
393 else {
394 0 return ( 0, 'New DrsUa message type!' );
395 }
396  
397 0 return ( \%info, '' );
398 }
399  
400 1 1;
401  
402  
403 __END__
« EPP/Verisign.pm ↑ Summary EPP/TCI.pm »