EPP/RIPN.pm

filter: Statementstmt 7.5% 31 / 412 Branchbran 0.0% 0 / 228 Conditioncond 0.0% 0 / 68 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 30.7% 8 / 26 Podpod 94.4% 17 / 18 totaltotal 7.0% 56 / 794 SCAR 100.4
CC
161
Cov
4%
update_registrar
600.0
cont_to_xml
552.0
new
462.0
CRAP 22824.0
↑ Summary EPP/Base.pm »
1 package IO::EPP::RIPN;
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 IO::EPP::RIPN
8  
9 =head1 SYNOPSIS
10  
11 use IO::EPP::RIPN;
12  
13 # Parameters for LWP
14 my %sock_params = (
15 PeerHost => 'uap.tcinet.ru',
16 PeerPort => 8028, # 8027 for .SU, 8028 for .RU, 8029 for .РФ
17 SSL_key_file => 'key_file.pem',
18 SSL_cert_file => 'cert_file.pem',
19 LocalAddr => '1.2.3.4',
20 Timeout => 30,
21 );
22  
23 # Create object, get greeting and call login()
24 my $conn = IO::EPP::RIPN->new( {
25 user => 'XXX-RU',
26 pass => 'XXXXXXXX',
27 sock_params => \%sock_params,
28 test_mode => 0, # real connect
29 } );
30  
31 # Check domain
32 my ( $answ, $code, $msg ) = $conn->check_domains( { domains => [ 'my.ru', 'out.ru' ] } );
33  
34 # Call logout() and destroy object
35 undef $conn;
36  
37 =head1 DESCRIPTION
38  
39 RIPN is the first organization the registry in the .ru tld.
40 Then it transferred functions of the registry into L<TCI|https://tcinet.ru>,
41 but all special headings in epp remained
42  
43 Examlpe:
44  
45 C<xsi:schemaLocation="http://www.ripn.net/epp/ripn-epp-1.0 ripn-epp-1.0.xsd">
46 instead of
47 C<xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
48  
49 Module overwrites IO::EPP::Base where there are differences from RFC
50 and work with tcinet epp using http api.
51  
52 For details see:
53 L<https://tcinet.ru/documents/RU-RF/TechRules.pdf>,
54 L<https://tcinet.ru/documents/RU-RF/P2_RIPN-EPP.pdf>,
55 L<https://tcinet.ru/documents/SU/SUTechRules.pdf>,
56 L<https://tcinet.ru/documents/SU/SU_P2_RipnEPP.pdf>.
57  
58 All documents -- L<https://tcinet.ru/documents/>.
59  
60 IO::EPP::RIPN only works with .RU, .SU & .РФ cctlds.
61  
62 For work with the new gtlds .ДЕТИ, .TATAR need use L<IO::EPP::TCI>.
63  
64 Features:
65  
66 Working over https;
67  
68 Completely other contacts;
69  
70 Non-standard domain transfer in the .su zone;
71  
72 The domain:check function has an error: when checking the availability of a blocked domain, it responds that it is available.
73 The list of blocked domains should be downloaded from the Registrar panel.
74  
75 =cut
76  
77 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 2 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 2 ▶use HTTP::Cookies;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 2 ▶use Time::HiRes qw( time );
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 2 ▶use IO::EPP::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 2 ▶use parent qw( IO::EPP::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
84  
85 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 # Old TCI uses special headings
89 2 our $epp_head = '<?xml version="1.0" encoding="UTF-8"?>
90 <epp xmlns="http://www.ripn.net/epp/ripn-epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ripn.net/epp/ripn-epp-1.0 ripn-epp-1.0.xsd">';
91 2 our $epp_cont_urn =
92 'xmlns:contact="http://www.ripn.net/epp/ripn-contact-1.0" xsi:schemaLocation="http://www.ripn.net/epp/ripn-contact-1.0 ripn-contact-1.0.xsd"';
93 2 our $epp_host_urn =
94 'xmlns:host="http://www.ripn.net/epp/ripn-host-1.0" xsi:schemaLocation="http://www.ripn.net/epp/ripn-host-1.0 ripn-host-1.0.xsd"';
95 2 our $epp_dom_urn =
96 'xmlns:domain="http://www.ripn.net/epp/ripn-domain-1.0" xsi:schemaLocation="http://www.ripn.net/epp/ripn-domain-1.0 ripn-domain-1.0.xsd"';
97 2 our $epp_dom_urn_ru =
98 'xmlns:domain="http://www.ripn.net/epp/ripn-domain-1.1" xsi:schemaLocation="http://www.ripn.net/epp/ripn-domain-1.1 ripn-domain-1.1.xsd"';
99 2 our $epp_reg_urn =
100 'xmlns:registrar="http://www.ripn.net/epp/ripn-registrar-1.0" xsi:schemaLocation="http://www.ripn.net/epp/ripn-registrar-1.0 ripn-registrar-1.0.xsd"';
101  
102  
103 sub make_request {
104 0 ▶ my ( $action, $params ) = @_;
Subroutine make_request: not called CC=11 SCAR=48.8
Pod documented
105  
106 #$params = IO::EPP::Base::recursive_utf8_unflaged( $params );
107  
108 0 my ( $code, $msg, $answ, $self );
109  
110 0 ▶ unless ( $params->{conn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'conn'}) { } 0 0 0
111 # Default:
112 0 ▶ $params->{sock_params}{PeerHost} ||= 'uap.tcinet.ru';
Condition0%0/2
$params->{"sock_params"}{"PeerHost"} ||= "uap.tcinet.ru"
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerHost"} ||= "uap.tcinet.ru"
$params->{"sock_params"}{"PeerHost"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerHost"}
Aresult
11
00
113 0 ▶ $params->{sock_params}{PeerPort} ||= 8028; # .RU
Condition0%0/2
$params->{"sock_params"}{"PeerPort"} ||= 8028
l!l
00
MC/DC0%0/1
$params->{"sock_params"}{"PeerPort"} ||= 8028
$params->{"sock_params"}{"PeerPort"}
Truth table0%0/2
A
A= $params->{"sock_params"}{"PeerPort"}
Aresult
11
00
114  
115 0 ( $self, $code, $msg ) = IO::EPP::RIPN->new( $params );
116  
117 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
118 0 goto END_MR;
119 }
120 }
121 else {
122 0 $self = $params->{conn};
123 }
124  
125 0 $self->{critical_error} = '';
126  
127 0 ▶ if ( $self->can( $action ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($action)) { } 0 0 0
128 0 ( $answ, $code, $msg ) = $self->$action( $params );
129 }
130 else {
131 0 $msg = "undefined command <$action>, request cancelled";
132 0 $code = 0;
133 }
134  
135 END_MR:
136  
137 0 ▶ $msg .= ', ' . $self->{critical_error} if $self->{critical_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"critical_error"} 0 0 0
138  
139 0 my $full_answ = "code: $code\nmsg: $msg";
140  
141 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
142  
143 0 $answ->{code} = $code;
144 0 $answ->{msg} = $msg;
145  
146 0 ▶ return wantarray ? ( $answ, $full_answ, $self ) : $answ;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
147 }
148  
149  
150 sub gen_pw {
151 0 ▶ my @chars = ( 'A'..'Z', 'a'..'z', '0'..'9', '!', '@', '$', '%', '*', '_', '.', ':', '-', '=', '+', '?', '#', ',' );
Subroutine gen_pw: not called CC=1 SCAR=6.9
Pod documented
152  
153 0 return join '', map( { $chars[ int rand( scalar @chars ) ] } 1..16 );
154 }
155  
156  
157 =head1 METHODS
158  
159 =head2 new
160  
161 If the C<alien_conn> parameter is received, it loads cookies from the file specified by C<load_cook_from>
162  
163 =cut
164  
165 sub new {
166 0 ▶ my ( $package, $params ) = @_;
Subroutine new: not called CC=21 SCAR=61.4
Pod documented
167  
168 0 my ( $self, $code, $msg );
169  
170 0 my $sock_params = delete $params->{sock_params};
171  
172 0 my $host = $sock_params->{PeerHost};
173 0 my $port = $sock_params->{PeerPort};
174 0 my $url = "https://$host:$port";
175 0 my $local_address = $sock_params->{LocalAddr};
176 0 ▶ my $timeout = $sock_params->{Timeout} || 5;
Condition0%0/2
$sock_params->{'Timeout'} || 5
l!l
00
MC/DC0%0/1
$sock_params->{'Timeout'} || 5
$sock_params->{'Timeout'}
Truth table0%0/2
A
A= $sock_params->{'Timeout'}
Aresult
11
00
177  
178 0 my %ua_params = ( ssl_opts => $sock_params );
179 0 ▶ $ua_params{local_address} = $local_address if $local_address;
Branch: 1 branch
BranchTrueFalseTotal
if $local_address 0 0 0
180  
181 0 ▶ if ( $timeout ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timeout) 0 0 0
182 # LWP feature: first param for LWP, second - for IO::Socket
183 0 $ua_params{timeout} = $timeout;
184 0 $ua_params{Timeout} = $timeout;
185 }
186  
187 0 my $cookie;
188 0 ▶ if ( $params->{alien_conn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{'alien_conn'}) { } 0 0 0
189 0 $cookie = HTTP::Cookies->new( autosave => 0 );
190  
191 0 ▶ unless ( $cookie->load( $params->{load_cook_from} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cookie->load($params->{"load_cook_from"})) 0 0 0
192 0 $msg = "load cooker is fail";
193 0 $code = 0;
194  
195 0 goto ERR;
196 }
197 }
198 else {
199 0 $cookie = HTTP::Cookies->new;
200 }
201  
202 0 my $ua = LWP::UserAgent->new(
203 agent => 'EppBot/7.02 (Perl; Linux i686; ru, en_US)',
204 parse_head => 0,
205 keep_alive => 30,
206 cookie_jar => $cookie,
207 %ua_params,
208 );
209  
210 0 ▶ unless ( $ua ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ua) 0 0 0
211 0 $msg = "can not connect";
212 0 $code = 0;
213  
214 0 goto ERR;
215 }
216  
217 $self = bless {
218 sock => $ua,
219 user => $params->{user},
220 url => $url,
221 cookies => $cookie,
222 no_log => delete $params->{no_log},
223 0 ▶ alien => $params->{alien_conn} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$params->{'alien_conn'} ? : 0 0 0
224 };
225  
226 0 $self->set_urn();
227  
228 0 $self->set_log_vars( $params );
229  
230 0 $self->epp_log( "Connect to $url\n" );
231  
232 0 ▶ if ( $self->{alien} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"alien"}) 0 0 0
233 0 ▶ return wantarray ? ( $self, 1000, 'ok' ) : $self;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
234 }
235  
236 # Get HEADER only
237 0 $self->epp_log( "HEAD connect to $url from $local_address" );
238  
239 0 my $request = HTTP::Request->new( HEAD => $url ); # не POST
240 0 my $response = $ua->request( $request );
241  
242 0 my $rcode = $response->code;
243 0 $self->epp_log( "header answ code: $rcode" );
244  
245 0 ▶ unless ( $rcode == 200 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rcode == 200) 0 0 0
246 0 $code = 0;
247 0 $msg = "Can't open socket";
248  
249 0 goto ERR;
250 }
251  
252 0 my $headers = $response->headers;
253  
254 0 my $length = $headers->content_length;
255 0 $self->epp_log( "header content-length == $length" );
256  
257 0 ▶ if ( $length == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length == 0) 0 0 0
258 0 $code = 0;
259 0 $msg = "Can't open socket";
260  
261 0 goto ERR;
262 }
263  
264 0 my ( undef, $c0, $m0 ) = $self->hello();
265  
266 0 ▶ unless ( $c0 && $c0 == 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($c0 and $c0 == 1000) 0 0 0
Condition0%0/3
$c0 and $c0 == 1000
!ll&&!rl&&r
000
MC/DC0%0/2
$c0 and $c0 == 1000
$c0 $c0 == 1000
Truth table0%0/3
A and B
A= $c0B= $c0 == 1000
ABresult
0X0
100
111
267 0 $code = 0;
268 0 $msg = "Can't get greeting";
269 0 ▶ $msg .= '; ' . $self->{critical_error} if $self->{critical_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"critical_error"} 0 0 0
270  
271 0 goto ERR;
272 }
273  
274  
275 0 my ( undef, $c1, $m1 ) = $self->login( delete $params->{pass} ); # no password in object
276  
277 0 ▶ if ( $c1 && $c1 == 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c1 and $c1 == 1000) 0 0 0
Condition0%0/3
$c1 and $c1 == 1000
!ll&&!rl&&r
000
MC/DC0%0/2
$c1 and $c1 == 1000
$c1 $c1 == 1000
Truth table0%0/3
A and B
A= $c1B= $c1 == 1000
ABresult
0X0
100
111
278 0 ▶ return wantarray ? ( $self, $c1, $m1 ) : $self;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
279 }
280  
281 0 ▶ $msg = ( $m1 || '' ) . $self->{critical_error};
Condition0%0/2
$m1 || ''
l!l
00
MC/DC0%0/1
$m1 || ''
$m1
Truth table0%0/2
A
A= $m1
Aresult
11
00
282 0 ▶ $code = $c1 || 0;
Condition0%0/2
$c1 || 0
l!l
00
MC/DC0%0/1
$c1 || 0
$c1
Truth table0%0/2
A
A= $c1
Aresult
11
00
283  
284 0 ▶ERR:
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
285 return wantarray ? ( 0, $code, $msg ) : 0;
286 }
287  
288  
289 sub set_urn {
290 $_[0]->{urn} = {
291 0 ▶ head => $IO::EPP::RIPN::epp_head,
Subroutine set_urn: not called CC=1 SCAR=6.9
Pod undocumented
292 cont => $IO::EPP::RIPN::epp_cont_urn,
293 host => $IO::EPP::RIPN::epp_host_urn,
294 dom => $IO::EPP::RIPN::epp_dom_urn,
295 reg => $IO::EPP::RIPN::epp_reg_urn,
296 };
297 }
298  
299  
300 sub req {
301 0 ▶ my ( $self, $out_data, $info ) = @_;
Subroutine req: not called CC=8 SCAR=42.8
Pod documented
302  
303 0 ▶ return 0 unless $out_data && $self->{sock};
Branch: 1 branch
BranchTrueFalseTotal
unless $out_data and $self->{"sock"} 0 0 0
Condition0%0/3
$out_data and $self->{"sock"}
!ll&&!rl&&r
000
MC/DC0%0/2
$out_data and $self->{"sock"}
$out_data $self->{"sock"}
Truth table0%0/3
A and B
A= $out_dataB= $self->{"sock"}
ABresult
0X0
100
111
304  
305 0 ▶ $info ||= '';
Condition0%0/2
$info ||= ""
l!l
00
MC/DC0%0/1
$info ||= ""
$info
Truth table0%0/2
A
A= $info
Aresult
11
00
306  
307 0 ▶ if ( $out_data ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out_data) 0 0 0
308 0 my $d = $out_data;
309 # remove password, authinfo from log
310 0 $d =~ s/<pw>[^<>]+<\/pw>/<pw>xxxxx<\/pw>/;
311  
312 0 $self->epp_log( "$info request:\n$d" );
313 }
314  
315 0 my $request = HTTP::Request->new( POST => $self->{url} );
316 0 $request->content_type('text/xml');
317 0 $request->content_type_charset('UTF-8');
318 0 $request->content( $out_data );
319  
320 0 my $start_time = time;
321  
322 0 my $response = $self->{sock}->request( $request );
323  
324 0 my $req_time = sprintf( '%0.4f', time - $start_time );
325  
326 # print Dumper $response;
327  
328 0 my $rcode = $response->code;
329  
330 0 ▶ unless ( $rcode == 200 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rcode == 200) 0 0 0
331 0 $self->{critical_error} = "Get answer code = $rcode";
332  
333 0 return 0;
334 }
335  
336 # feature of connection on epp over https
337 0 ▶ if ( $info eq 'login' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info eq "login") 0 0 0
338 0 $self->{cook} = $self->{sock}->cookie_jar->as_string;
339 0 $self->epp_log( "cookies: $$self{cook}" );
340  
341 0 ▶ $self->{sessionid} = $response->header('set-cookie') || '';
Condition0%0/2
$response->header('set-cookie') || ''
l!l
00
MC/DC0%0/1
$response->header('set-cookie') || ''
$response->header('set-cookie')
Truth table0%0/2
A
A= $response->header('set-cookie')
Aresult
11
00
342 0 $self->epp_log( "sessionid: $$self{sessionid}" );
343 }
344  
345 0 my $in_data = $response->content;
346  
347 0 $self->epp_log( "req_time: $req_time\n$info answer:\n$in_data\n" );
348  
349 0 return $in_data;
350 }
351  
352  
353 =head2 login
354  
355 Ext params for login,
356  
357 INPUT: new password for change
358  
359 =cut
360  
361 sub login {
362 0 ▶ my ( $self, $pw, undef, undef, $new_pw ) = @_;
Subroutine login: not called CC=4 SCAR=30.0
Pod documented
363  
364 0 ▶ return 0 unless $pw;
Branch: 1 branch
BranchTrueFalseTotal
unless $pw 0 0 0
365  
366 0 ▶ my $npw = $new_pw ? "\n <newPW>$new_pw</newPW>" : '';
Branch: 1 branch
BranchTrueFalseTotal
$new_pw ? : 0 0 0
367  
368 0 my ( $svcs, $ext ) = ( '', '' );
369  
370 0 ▶ if ( $self->{user} =~ /-(RU|RF)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"user"} =~ /-(RU|RF)$/) 0 0 0
371 0 $svcs = "\n <objURI>http://www.ripn.net/epp/ripn-domain-1.1</objURI>";
372 # Does not work $ext = "\n <extURI>http://www.tcinet.ru/epp/tci-billing-1.0</extURI>";
373 }
374  
375 0 my $cltrid = $self->get_cltrid();
376  
377 0 my $body = <<LOGIN;
378 $$self{urn}{head}
379 <command>
380 <login>
381 <clID>$$self{user}</clID>
382 <pw>$pw</pw>$npw
383 <options>
384 <version>1.0</version>
385 <lang>en</lang>
386 </options>
387 <svcs>
388 <objURI>http://www.ripn.net/epp/ripn-contact-1.0</objURI>
389 <objURI>http://www.ripn.net/epp/ripn-domain-1.0</objURI>$svcs
390 <objURI>http://www.ripn.net/epp/ripn-epp-1.0</objURI>
391 <objURI>http://www.ripn.net/epp/ripn-eppcom-1.0</objURI>
392 <objURI>http://www.ripn.net/epp/ripn-host-1.0</objURI>
393 <objURI>http://www.ripn.net/epp/ripn-registrar-1.0</objURI>
394 <svcExtension>
395 <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>$ext
396 </svcExtension>
397 </svcs>
398 </login>
399 <clTRID>$cltrid</clTRID>
400 </command>
401 </epp>
402 LOGIN
403  
404 0 return $self->simple_request( $body, 'login' );
405 }
406  
407  
408 =head2 save_cookies
409  
410 Save http connection cookies,
411 they can be used to create another connection on this IP address without opening a new session, that is, without a login
412  
413 =cut
414  
415 sub save_cookies {
416 0 ▶ my ( $self, $params ) = @_;
Subroutine save_cookies: not called CC=6 SCAR=37.4
Pod documented
417  
418 0 ▶ unless ( ref $params and $params->{save_cook_to} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $params and $params->{"save_cook_to"}) 0 0 0
Condition0%0/3
ref $params and $params->{"save_cook_to"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $params and $params->{"save_cook_to"}
ref $params $params->{"save_cook_to"}
Truth table0%0/3
A and B
A= ref $paramsB= $params->{"save_cook_to"}
ABresult
0X0
100
111
419 0 ▶ return wantarray ? ( 0, 0, 'no params' ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
420 }
421  
422 0 my $cook = $self->{sock}->cookie_jar->as_string;
423  
424 0 ▶ open( COOKFILE, '>', $params->{save_cook_to} ) or return ( 0, 0, "Can't open $$params{save_cook_to} file: $!" );
Branch: 1 branch
BranchTrueFalseTotal
open COOKFILE, ">", $params->{"save_cook_to"} or return 0, 0, qq[Can't open $params->{"save_cook_to"} file: $!] 0 0 0
425 0 print COOKFILE "#LWP-Cookies-1.0\n";
426 0 print COOKFILE "$cook\n";
427 0 close COOKFILE;
428  
429 0 my %info = ( cook => $cook );
430 0 $self->{cook} = $cook;
431  
432 0 ▶ return wantarray ? ( \%info, 1000, 'ok' ) : \%info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
433 }
434  
435  
436 =head2 hello
437  
438 For details, see L<IO::EPP::Base/hello>
439  
440 =cut
441  
442 sub hello {
443 0 ▶ my ( $self ) = @_;
Subroutine hello: not called CC=4 SCAR=30.0
Pod documented
444  
445 0 my $body = <<HELLO;
446 $$self{urn}{head}
447 <hello/>
448 </epp>
449 HELLO
450  
451 0 my $content = $self->req( $body, 'hello' );
452  
453 0 ▶ return 0 unless $content && $content =~ /greeting/;
Branch: 1 branch
BranchTrueFalseTotal
unless $content and $content =~ /greeting/ 0 0 0
Condition0%0/3
$content and $content =~ /greeting/
!ll&&!rl&&r
000
MC/DC0%0/2
$content and $content =~ /greeting/
$content $content =~ /greeting/
Truth table0%0/3
A and B
A= $contentB= $content =~ /greeting/
ABresult
0X0
100
111
454  
455 0 my $info = { code => 1000, msg => $content };
456  
457 0 ▶ return wantarray ? ( $info, 1000, $content ) : $info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
458 }
459  
460 =head2 cont_to_xml
461  
462 Overrides the base class converter, since the contacts are very different here.
463  
464 =cut
465  
466 sub cont_to_xml {
467 0 ▶ my ( undef, $cont ) = @_;
Subroutine cont_to_xml: not called CC=23 SCAR=63.1
Pod documented
468  
469 0 ▶ my $is_person = $cont->{passport} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$cont->{'passport'} ? : 0 0 0
470  
471 0 ▶ my $txtcont .= $is_person ? "<contact:person>\n" : "<contact:organization>\n";
Branch: 1 branch
BranchTrueFalseTotal
$is_person ? : 0 0 0
472  
473 0 foreach my $type ( 'int', 'loc' ) {
474 0 $txtcont .= " <contact:".$type."PostalInfo>\n";
475  
476 0 ▶ if ( $is_person ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_person) { } 0 0 0
477 0 $txtcont .= " <contact:name>".$$cont{$type}{name}."</contact:name>\n";
478 }
479 else {
480 0 $txtcont .= " <contact:org>".$$cont{$type}{org}."</contact:org>\n";
481 }
482  
483 0 ▶ $$cont{$type}{addr} = [ $$cont{$type}{addr} ] unless ref $$cont{$type}{addr};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{$type}{"addr"} 0 0 0
484  
485 0 $txtcont .= " <contact:address>$_</contact:address>\n" foreach @{$$cont{$type}{addr}};
486  
487 0 $txtcont .= " </contact:".$type."PostalInfo>\n";
488 }
489  
490 0 ▶ unless ( $is_person ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_person) 0 0 0
491 0 $txtcont .= " <contact:legalInfo>\n";
492  
493 0 ▶ $$cont{legal}{addr} = [ $$cont{legal}{addr} ] unless ref $$cont{legal}{addr};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{"legal"}{"addr"} 0 0 0
494  
495 0 $txtcont .= " <contact:address>$_</contact:address>\n" foreach @{$$cont{legal}{addr}};
496  
497 0 $txtcont .= " </contact:legalInfo>\n";
498 }
499  
500 0 ▶ if ( $$cont{taxpayerNumbers} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont->{'taxpayerNumbers'}) { } 0 0 0
501 0 $txtcont .= " <contact:taxpayerNumbers>$$cont{TIN}</contact:taxpayerNumbers>\n";
502 }
503 else {
504 0 $txtcont .= " <contact:taxpayerNumbers/>\n";
505 }
506  
507 0 ▶ if ( $is_person ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_person) 0 0 0
508 0 $txtcont .= " <contact:birthday>$$cont{birthday}</contact:birthday>\n";
509  
510 0 ▶ $$cont{passport} = [ $$cont{passport} ] unless ref $$cont{passport};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{"passport"} 0 0 0
511  
512 0 $txtcont .= " <contact:passport>$_</contact:passport>\n" foreach @{$$cont{passport}};
513 }
514  
515 0 ▶ $$cont{phone} = [ $$cont{phone} ] unless ref $$cont{phone};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{"phone"} 0 0 0
516  
517 0 $txtcont .= " <contact:voice>$_</contact:voice>\n" foreach @{$$cont{phone}};
518  
519 0 ▶ if ( $$cont{fax} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont->{'fax'}) { } 0 0 0
520 0 ▶ $$cont{fax} = [ $$cont{fax} ] unless ref $$cont{fax};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{"fax"} 0 0 0
521  
522 0 $txtcont .= " <contact:fax>$_</contact:fax>\n" foreach @{$$cont{fax}};
523 }
524 else {
525 0 $txtcont .= " <contact:fax/>\n";
526 }
527  
528 0 ▶ $$cont{email} = [ $$cont{email} ] unless ref $$cont{email};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cont->{"email"} 0 0 0
529  
530 0 $txtcont .= " <contact:email>$_</contact:email>\n" foreach @{$$cont{email}};
531  
532 0 ▶ if ( $is_person ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_person) { } 0 0 0
533 0 $txtcont .= " </contact:person>\n";
534 }
535 else {
536 0 $txtcont .= " </contact:organization>\n";
537 }
538  
539 0 ▶ if ( $$cont{verified} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cont->{'verified'}) { } 0 0 0
540 0 $txtcont .= " <contact:verified/>";
541 }
542 else {
543 0 $txtcont .= " <contact:unverified/>";
544 }
545  
546 0 return $txtcont;
547 }
548  
549  
550 =head2 create_contact
551  
552 Parameter names are maximally unified with other providers.
553  
554 INPUT:
555  
556 for individual:
557  
558 C<name> — full name, need for C<int> and C<loc> types;
559  
560 C<birthday> — date of birth;
561  
562 C<passport> — identification card number, place and date of issue;
563  
564 for legal entity:
565  
566 C<org> — organization name
567  
568 C<addr> — string or array with full legal address of the organization, need for C<legal> type data
569  
570 common fields:
571  
572 C<addr> — string or array with full address;
573  
574 C<TIN> - taxpayer numbers;
575  
576 C<phone> – string or array with phone numbers in international format,
577 you can specify a list of multiple phones,
578 the suffixes C<(sms)> and C<(transfer)> are used to mark phones for confirming transfers;
579  
580 C<fax> – string or array with faxes, usually only required for legal entities;
581  
582 C<email>;
583  
584 C<verified> – the full name or name of the organization was confirmed by documents.
585  
586 Examples:
587  
588 Create person contact
589  
590 my %pers = (
591 cont_id => 'MY-123456',
592 'int' => {
593 name => 'Igor I Igover',
594 addr => 'UA, 12345, Igorevsk, Igoreva str, 13',
595 },
596 loc => {.
597 name => 'Игорь Игоревич Игорев',.
598 addr => [ 'UA', '85012', 'Игоревск', 'ул. Игорева, д.12, Игореву И.И.' ],
599 },
600 TIN => '',
601 birthday => '2001-01-01',
602 passport => [ 'II662244', 'выдан Игоревским МВД УДМС', '1.1.2017' ],
603 phone => '+380.501234567',
604 fax => '',
605 email => 'mail@igor.name',
606 );
607  
608 my ( $answ, $code, $msg ) = $conn->create_contact( \%pers );
609  
610 # answer
611  
612 {
613 'cont_id' => 'my-123456',
614 'cre_date' => '2020-01-11 10:10:10',
615 'cltrid' => '1710de82a0e9249277ffd713f51c8888',
616 'svtrid' => '4997598888'
617 };
618  
619 Create legal entity contact
620  
621 my %org = (
622 # cont_id - auto
623 'int' => {.
624 org => 'Igor Limited Liability Company',
625 addr => [ 'RU', '123456', 'Moscow', 'Igoreva str, 3', 'Igor LLC' ]
626 },
627 loc => {
628 org => 'ООО «Игорь»',
629 addr => [ 'RU, 123456, г. Москва, ул. Игорева, дом 3, ООО «Игорь»', 'охраннику' ],
630 },
631 legal => {.
632 addr => [ '125476, г.Москва, ул. Игорева, д.3' ],
633 },
634 TIN => '7777777777',
635 phone => [ '+7.4951111111', '+7.4951111111(transfer)' ],
636 fax => '+7.4951111111',
637 email => [ 'mail@igor.ru' ],
638 );
639  
640 my ( $answ, $code, $msg ) = $conn->create_contact( \%org );
641  
642 # answer
643  
644 {
645 'cont_id' => 'e88c1fngsz1e',
646 'cre_date' => '2020-01-01 10:10:10',
647 'cltrid' => '6194b816dd3f5d3f417fd2cfe0c88888',
648 'svtrid' => '4997633333'
649 };
650  
651 =cut
652  
653 sub create_contact {
654 0 ▶ my ( $self, $params ) = @_;
Subroutine create_contact: not called CC=2 SCAR=17.9
Pod documented
655  
656 0 ▶ $params->{cont_id} ||= IO::EPP::Base::gen_id( 16 );
Condition0%0/3
$params->{"cont_id"} ||= IO::EPP::Base::gen_id(16)
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"cont_id"} ||= IO::EPP::Base::gen_id(16)
$params->{"cont_id"} IO::EPP::Base::gen_id(16)
Truth table0%0/3
A ||= B
A= $params->{"cont_id"}B= IO::EPP::Base::gen_id(16)
ABresult
1X1
011
000
657  
658 0 return $self->SUPER::create_contact( $params );
659 }
660  
661  
662 =head2 cont_from_xml
663  
664 Overrides the base class contact parser.
665  
666 As a result, the get_contact_info function displays the request response in the registry as follows:
667  
668 Individual
669  
670 my ( $a, $m, $o ) = make_request( 'get_contact_info', { cont_id => 'my-123456' } );
671  
672 # answer
673  
674 {
675 'msg' => 'Command completed successfully',
676 'owner' => 'XXX-RU',
677 'int' => {
678 'name' => 'Igor I Igover',
679 'addr' => [
680 'UA, 12345, Igorevsk, Igoreva str, 13'
681 ]
682 },
683 'cre_date' => '2020-01-10 10:10:10',
684 'phone' => [
685 '+380.501234567'
686 ],
687 'email' => [
688 'mail@igor.name'
689 ],
690 'loc' => {
691 'name' => 'Игорь Игоревич Игорев',
692 'addr' => [
693 'UA',
694 '85012',
695 'Игоревск',
696 'ул. Игорева, д.12, Игореву И.И.'
697 ]
698 },
699 'fax' => [],
700 'creater' => 'XXX-RU',
701 'verified' => 0,
702 'statuses' => {
703 'ok' => '+'
704 },
705 'birthday' => '2001-01-01',
706 'passport' => [
707 'II662244',
708 'выдан Игоревским МВД УДМС',
709 '1.1.2017'
710 ],
711 'code' => '1000'
712 };
713  
714 Legal entity
715  
716 my ( $a, $m, $o ) = make_request( 'get_contact_info', { cont_id => 'e88c1fngsz1e' } );
717  
718 # answer
719  
720 {
721 'msg' => 'Command completed successfully',
722 'owner' => 'XXX-RU',
723 'int' => {
724 'org' => 'Igor Limited Liability Company',
725 'addr' => [
726 'RU',
727 '123456',
728 'Moscow',
729 'Igoreva str, 3',
730 'Igor LLC'
731 ]
732 },
733 'cre_date' => '2020-01-10 10:10:10',
734 'phone' => [
735 '+7.4951111111',
736 '+7.4951111111(transfer)'
737 ],
738 'email' => [
739 'mail@igor.ru'
740 ],
741 'loc' => {
742 'org' => 'ООО «Игорь»',
743 'addr' => [
744 'RU, 123456, г. Москва, ул. Игорева, дом 3, ООО «Игорь»',
745 'охраннику'
746 ]
747 },
748 'fax' => [
749 '+7.4951111111'
750 ],
751 'legal' => {
752 'addr' => [
753 '125476, г.Москва, ул. Игорева, д.3'
754 ]
755 },
756 'creater' => 'XXX-RU',
757 'verified' => 0,
758 'statuses' => {
759 'ok' => '+'
760 },
761 'code' => '1000'
762 };
763  
764 =cut
765  
766 sub cont_from_xml {
767 0 ▶ my ( undef, $txtcont ) = @_;
Subroutine cont_from_xml: not called CC=16 SCAR=56.1
Pod documented
768  
769 0 my %cont;
770  
771 0 ▶ my $is_person = ($txtcont =~ /contact:person/) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$txtcont =~ /contact:person/ ? : 0 0 0
772  
773 0 my @ss = $txtcont =~ /<contact:status s="([^"]+)"\/>/g;
774 0 $cont{statuses}{$_} = '+' for @ss;
775  
776 0 my %types = ( intPostalInfo => 'int', locPostalInfo => 'loc', legalInfo => 'legal' );
777 0 foreach my $type ( keys %types ) {
778 0 ▶ if ( $txtcont =~ /<contact:$type>(.+)<\/contact:$type>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:$type>(.+)</contact:$type>]s) 0 0 0
779 0 my $pi = $1;
780  
781 0 ▶ if ( $pi =~ /<contact:name>([^<>]+)<\/contact:name>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pi =~ m[<contact:name>([^<>]+)</contact:name>]) 0 0 0
782 0 $cont{$types{$type}}{name} = $1;
783 }
784 0 ▶ if ( $pi =~ /<contact:org>([^<>]+)<\/contact:org>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pi =~ m[<contact:org>([^<>]+)</contact:org>]) 0 0 0
785 0 $cont{$types{$type}}{org} = $1;
786 }
787  
788 0 $cont{$types{$type}}{addr} = [ $pi =~ /<contact:address>([^<>]+)<\/contact:address>/g ];
789 }
790 }
791  
792 0 ▶ if ( $txtcont =~ /<contact:taxpayerNumbers>([^<>]+)<\/contact:taxpayerNumbers>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:taxpayerNumbers>([^<>]+)</contact:taxpayerNumbers>]) 0 0 0
793 0 $cont{TIN} = $1;
794 }
795  
796 0 ▶ if ( $is_person ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_person) 0 0 0
797 0 ▶ if ( $txtcont =~ /<contact:birthday>([^<>]+)<\/contact:birthday>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:birthday>([^<>]+)</contact:birthday>]) 0 0 0
798 0 $cont{birthday} = $1;
799 }
800  
801 0 $cont{passport} = [ $txtcont =~ /<contact:passport>([^<>]+)<\/contact:passport>/g ];
802 }
803  
804 0 $cont{phone} = [ $txtcont =~ /<contact:voice>([^<>]+)<\/contact:voice>/g ];
805  
806 0 $cont{fax} = [ $txtcont =~ /<contact:fax>([^<>]+)<\/contact:fax>/g ];
807  
808 0 $cont{email} = [ $txtcont =~ /<contact:email>([^<>]+)<\/contact:email>/g ];
809  
810 0 ▶ if ( $txtcont =~ /<contact:verified\/>/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:verified/>]) { } 0 0 0
elsif ($txtcont =~ m[<contact:unverified/>]) { } 0 0 0
811 0 $cont{verified} = 1;
812 }
813 elsif ( $txtcont =~ /<contact:unverified\/>/ ) {
814 0 $cont{verified} = 0;
815 }
816  
817 0 my %id = %IO::EPP::Base::id;
818 0 foreach my $k ( keys %id ) {
819 0 ▶ if ( $txtcont =~ /<contact:$k>([^<>]+)<\/contact:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:$k>([^<>]+)</contact:$k>]) 0 0 0
820 0 $cont{$id{$k}} = $1;
821 }
822 }
823  
824 0 my %dt = %IO::EPP::Base::dt;
825 0 foreach my $k ( keys %dt ) {
826 0 ▶ if ( $txtcont =~ /<contact:$k>([^<>]+)<\/contact:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($txtcont =~ m[<contact:$k>([^<>]+)</contact:$k>]) 0 0 0
827 0 $cont{$dt{$k}} = $1;
828  
829 0 $cont{$dt{$k}} =~ s/T/ /;
830 0 $cont{$dt{$k}} =~ s/\.\d+Z$//;
831 }
832 }
833  
834 0 return \%cont;
835 }
836  
837  
838 =head2 transfer
839  
840 Addition parameter for .SU, .NET.RU, .ORG.RU, .PP.RU:
841 C<sent_to> - registrar name which will receive the domain (here all on the contrary)
842  
843 =cut
844  
845 sub transfer {
846 0 ▶ my ( $self, $params ) = @_;
Subroutine transfer: not called CC=3 SCAR=24.8
Pod documented
847  
848 0 ▶ if ( $params->{to} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"to"}) 0 0 0
849 0 $params->{addition} = "\n <domain:acID>$$params{sent_to}</domain:acID>";
850 }
851  
852 0 ▶ if ( $params->{user} =~ /-(RU|RF)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"user"} =~ /-(RU|RF)$/) 0 0 0
853 0 $self->{urn}{dom} = $epp_dom_urn_ru;
854 }
855  
856 0 my @res = $self->SUPER::transfer( $params );
857  
858 0 $self->{urn}{dom} = $IO::EPP::RIPN::epp_dom_urn;
859  
860 0 return @res;
861 }
862  
863  
864 =head2 get_registrar_info
865  
866 Get Registrar data: white IP, email, whois data
867  
868 =cut
869  
870 sub get_registrar_info {
871 0 ▶ my ( $self ) = @_;
Subroutine get_registrar_info: not called CC=21 SCAR=61.4
Pod documented
872  
873 0 my $cltrid = $self->get_cltrid();
874  
875 0 my $body = <<REGINFO;
876 $$self{urn}{head}
877 <command>
878 <info>
879 <registrar:info $$self{urn}{reg}>
880 <registrar:id>$$self{user}</registrar:id>
881 </registrar:info>
882 </info>
883 <clTRID>$cltrid</clTRID>
884 </command>
885 </epp>
886 REGINFO
887  
888 0 my $answ = $self->req( $body, 'registrar_info' );
889  
890 0 ▶ if ( $answ && $answ =~ /<result code="(\d+)">/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ and $answ =~ /<result code="(\d+)">/) 0 0 0
Condition0%0/3
$answ and $answ =~ /<result code="(\d+)">/
!ll&&!rl&&r
000
MC/DC0%0/2
$answ and $answ =~ /<result code="(\d+)">/
$answ $answ =~ /<result code="(\d+)">/
Truth table0%0/3
A and B
A= $answB= $answ =~ /<result code="(\d+)">/
ABresult
0X0
100
111
891 0 my $rcode = $1 + 0;
892  
893 0 my $msg = '';
894 0 ▶ if ( $answ =~ /<result.+<msg[^<>]*>(.+)<\/msg>.+\/result>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<result.+<msg[^<>]*>(.+)</msg>.+/result>]s) 0 0 0
895 0 $msg = $1;
896 }
897  
898 0 ▶ if ( $rcode != 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rcode != 1000) 0 0 0
899 0 ▶ if ( $answ =~ /<reason>(.+)<\/reason>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<reason>(.+)</reason>]s) 0 0 0
900 0 $msg .= '; ' . $1;
901 }
902  
903 0 ▶ return wantarray ? ( 0, $rcode, $msg ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
904 }
905  
906 0 my $info = {};
907  
908 0 ▶ if ( $answ =~ /<resData>(.+)<\/resData>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<resData>(.+)</resData>]s) 0 0 0
909 0 ▶ my $rdata = $1 // '';
Condition0%0/2
$1 // ""
l!l
00
MC/DC0%0/1
$1 // ""
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
910  
911 0 my %types = ( intPostalInfo => 'int', locPostalInfo => 'loc', legalInfo => 'legal' );
912 0 foreach my $type ( keys %types ) {
913 0 ▶ if ( $rdata =~ /<registrar:$type>(.+)<\/registrar:$type>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<registrar:$type>(.+)</registrar:$type>]s) 0 0 0
914 0 my $pi = $1;
915 0 ▶ if ( $pi =~ /<registrar:org>([^<>]+)<\/registrar:org>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pi =~ m[<registrar:org>([^<>]+)</registrar:org>]) 0 0 0
916 0 $info->{$types{$type}}{org} = $1;
917 }
918  
919 0 $info->{$types{$type}}{addr} = join(', ', $pi =~ /<registrar:address>([^<>]+)<\/registrar:address>/g );
920 }
921 }
922  
923 0 ▶ if ( $rdata =~ /<registrar:taxpayerNumbers>([^<>]+)<\/registrar:taxpayerNumbers>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<registrar:taxpayerNumbers>([^<>]+)</registrar:taxpayerNumbers>]) 0 0 0
924 0 $info->{TIN} = $1;
925 }
926  
927 0 $info->{phone} = [ $rdata =~ /<registrar:voice>([^<>]+)<\/registrar:voice>/g ];
928  
929 0 $info->{fax} = [ $rdata =~ /<registrar:fax>([^<>]+)<\/registrar:fax>/g ];
930  
931 0 my @emails = $rdata =~ /(<registrar:email type="[^"]+">[^<>]+<\/registrar:email>)/g;
932  
933 0 foreach my $e ( @emails ) {
934 0 ▶ if ( $e =~ /registrar:email type="([^"]+)">([^<>]+)<\/registrar:email/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ m[registrar:email type="([^"]+)">([^<>]+)</registrar:email]) 0 0 0
935 0 $info->{emails}{$1} = $2;
936 }
937 }
938  
939 0 ▶ if ( $rdata =~ /<registrar:www>([^<>]+)<\/registrar:www>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<registrar:www>([^<>]+)</registrar:www>]) 0 0 0
940 0 $info->{www} = $1;
941 }
942  
943 0 ▶ if ( $rdata =~ /<registrar:whois>([^<>]+)<\/registrar:whois>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<registrar:whois>([^<>]+)</registrar:whois>]) 0 0 0
944 0 $info->{whois} = $1;
945 }
946  
947 0 $info->{ips} = [ $rdata =~ /<registrar:addr ip="v\d">([0-9A-Fa-f.:]+)<\/registrar:addr>/g ];
948  
949 0 my %dt = %IO::EPP::Base::dt;
950 0 foreach my $k ( keys %dt ) {
951 0 ▶ if ( $rdata =~ /<registrar:$k>([^<>]+)<\/registrar:$k>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rdata =~ m[<registrar:$k>([^<>]+)</registrar:$k>]) 0 0 0
952 0 $info->{$dt{$k}} = $1;
953  
954 0 $info->{$dt{$k}} =~ s/T/ /;
955 0 $info->{$dt{$k}} =~ s/\.\d+Z$//;
956 }
957 }
958 }
959  
960 0 ▶ return wantarray ? ( $info, $rcode, $msg ) : $info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
961 }
962  
963 0 ▶ return wantarray ? ( 0, 0, 'empty answer' ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
964 }
965  
966  
967 =head2 update_registrar
968  
969 Changing Registrar data: white IP, email, whois data
970  
971 INPUT:
972  
973 key of params:
974  
975 C<add> or C<rem>:
976  
977 C<ips> -- arrayref of ipv4 or ipv6 address,
978  
979 C<emails> - hashref where keys - email type, values - email
980  
981 C<chg>:
982  
983 C<www> - new web url
984  
985 C<whois> - new whois url
986  
987 =cut
988  
989 sub update_registrar {
990 0 ▶ my ( $self, $params ) = @_;
Subroutine update_registrar: not called CC=24 SCAR=64.0
Pod documented
991  
992 0 ▶ return ( 0, 0, 'no params' ) unless ref $params;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params 0 0 0
993  
994 0 my $cltrid = $self->get_cltrid();
995  
996 0 my $add = '';
997 0 ▶ if ( $params->{add} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"add"}) 0 0 0
998 0 ▶ if ( defined $params->{add}{ips} and ref $params->{add}{ips} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"add"}{"ips"} and ref $params->{"add"}{"ips"}) 0 0 0
Condition0%0/3
defined $params->{"add"}{"ips"} and ref $params->{"add"}{"ips"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"add"}{"ips"} and ref $params->{"add"}{"ips"}
defined $params->{"add"}{"ips"} ref $params->{"add"}{"ips"}
Truth table0%0/3
A and B
A= defined $params->{"add"}{"ips"}B= ref $params->{"add"}{"ips"}
ABresult
0X0
100
111
999 0 foreach my $ip ( @{$params->{add}{ips}} ) {
1000 0 ▶ if ( $ip =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { } 0 0 0
1001 0 $add .= ' <registrar:addr ip="v4">' . $ip . "</registrar:addr>\n";
1002 }
1003 else {
1004 0 $add .= ' <registrar:addr ip="v6">' . $ip . "</registrar:addr>\n";
1005 }
1006 }
1007 }
1008  
1009 0 ▶ if ( defined $params->{add}{emails} and ref $params->{add}{emails} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"add"}{"emails"} and ref $params->{"add"}{"emails"}) 0 0 0
Condition0%0/3
defined $params->{"add"}{"emails"} and ref $params->{"add"}{"emails"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"add"}{"emails"} and ref $params->{"add"}{"emails"}
defined $params->{"add"}{"emails"} ref $params->{"add"}{"emails"}
Truth table0%0/3
A and B
A= defined $params->{"add"}{"emails"}B= ref $params->{"add"}{"emails"}
ABresult
0X0
100
111
1010 0 foreach my $type ( @{$params->{add}{emails}} ) {
1011 0 $add .= qq| <registrar:emailtype="$type">| . $$params{add}{emails}{$type} . "</registrar:email>\n";
1012 }
1013 }
1014 }
1015  
1016 0 ▶ if ( $add ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add) { } 0 0 0
1017 0 $add = "<registrar:add>\n$add </registrar:add>";
1018 }
1019 else {
1020 0 $add = '<registrar:add/>'
1021 }
1022  
1023 0 my $rem = '';
1024 0 ▶ if ( $params->{rem} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"rem"}) 0 0 0
1025 0 ▶ if ( defined $params->{rem}{ips} && ref $params->{rem}{ips} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"rem"}{"ips"} and ref $params->{"rem"}{"ips"}) 0 0 0
Condition0%0/3
defined $params->{"rem"}{"ips"} and ref $params->{"rem"}{"ips"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"rem"}{"ips"} and ref $params->{"rem"}{"ips"}
defined $params->{"rem"}{"ips"} ref $params->{"rem"}{"ips"}
Truth table0%0/3
A and B
A= defined $params->{"rem"}{"ips"}B= ref $params->{"rem"}{"ips"}
ABresult
0X0
100
111
1026 0 foreach my $ip ( @{$params->{rem}{ips}} ) {
1027 0 ▶ if ( $ip =~ /^\d+\.\d+\.\d+\.\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ip =~ /^\d+\.\d+\.\d+\.\d+$/) { } 0 0 0
1028 0 $rem .= ' <registrar:addr ip="v4">' . $ip . "</registrar:addr>\n";
1029 }
1030 else {
1031 0 $rem .= ' <registrar:addr ip="v6">' . $ip . "</registrar:addr>\n";
1032 }
1033 }
1034 }
1035  
1036 0 ▶ if ( defined $params->{rem}{emails} and ref $params->{rem}{emails} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params->{"rem"}{"emails"} and ref $params->{"rem"}{"emails"}) 0 0 0
Condition0%0/3
defined $params->{"rem"}{"emails"} and ref $params->{"rem"}{"emails"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params->{"rem"}{"emails"} and ref $params->{"rem"}{"emails"}
defined $params->{"rem"}{"emails"} ref $params->{"rem"}{"emails"}
Truth table0%0/3
A and B
A= defined $params->{"rem"}{"emails"}B= ref $params->{"rem"}{"emails"}
ABresult
0X0
100
111
1037 0 foreach my $type ( @{$params->{rem}{emails}} ) {
1038 0 $rem .= qq| <registrar:emailtype="$type">| . $$params{rem}{emails}{$type} . "</registrar:email>\n";
1039 }
1040 }
1041 }
1042  
1043 0 ▶ if ( $rem ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rem) { } 0 0 0
1044 0 $rem = "<registrar:rem>\n$rem </registrar:rem>";
1045 }
1046 else {
1047 0 $rem = '<registrar:rem/>'
1048 }
1049  
1050 0 my $chg = '';
1051 0 ▶ if ( $params->{chg} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"chg"}) 0 0 0
1052 0 ▶ if ( $params->{chg}{www} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"chg"}{"www"}) 0 0 0
1053 0 $chg .= ' <registrar:www>' . $$params{chg}{www} . "</registrar:www>\n";
1054 }
1055  
1056 0 ▶ if ( $params->{chg}{whois} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"chg"}{"whois"}) 0 0 0
1057 0 $chg .= ' <registrar:whois>' . $$params{chg}{www} . "</registrar:whois>\n";
1058 }
1059 }
1060  
1061 0 ▶ if ( $chg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chg) { } 0 0 0
1062 0 $chg = "<registrar:chg>\n$chg </registrar:chg>";
1063 }
1064 else {
1065 0 $chg = "<registrar:chg/>";
1066 }
1067  
1068  
1069 0 my $body = <<UPDREG;
1070 $$self{urn}{head}
1071 <command>
1072 <update>
1073 <registrar:update $$self{urn}{reg}>
1074 <registrar:id>$$self{user}</registrar:id>
1075 $add
1076 $rem
1077 $chg
1078 </registrar:update>
1079 </update>
1080 <clTRID>$cltrid</clTRID>
1081 </command>
1082 </epp>
1083 UPDREG
1084  
1085 0 return $self->simple_request( $body, 'update_registrar' );
1086 }
1087  
1088  
1089 =head2 get_billing_info
1090  
1091 INPUT:
1092  
1093 keys of params:
1094  
1095 C<date>,
1096  
1097 C<period>: in days,
1098  
1099 C<currency>: RUB.
1100  
1101 =cut
1102  
1103 sub get_billing_info {
1104 0 ▶ my ( $self, $params ) = @_;
Subroutine get_billing_info: not called CC=14 SCAR=53.5
Pod documented
1105  
1106 0 ▶ return ( 0, 0, 'no params' ) unless ref $params;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params 0 0 0
1107  
1108 0 my $cltrid = $self->get_cltrid();
1109  
1110 0 my $body = <<BILINFO;
1111 $$self{urn}{head}
1112 <command>
1113 <info>
1114 <billing:info xmlns:billing="http://www.tcinet.ru/epp/tci-billing-1.0">
1115 <billing:type>balance</billing:type>
1116 <billing:param>
1117 <billing:date>$$params{date}</billing:date>
1118 <billing:period unit="d">$$params{period}</billing:period>
1119 <billing:currency>$$params{currency}</billing:currency>
1120 </billing:param>
1121 </billing:info>
1122 </info>
1123 <clTRID>$cltrid</clTRID>
1124 </command>
1125 </epp>
1126 BILINFO
1127  
1128 0 my $answ = $self->req( $body, 'billing_info' );
1129  
1130 0 ▶ if ( $answ && $answ =~ /<result code=['"](\d+)['"]>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ and $answ =~ /<result code=['"](\d+)['"]>/) 0 0 0
Condition0%0/3
$answ and $answ =~ /<result code=['"](\d+)['"]>/
!ll&&!rl&&r
000
MC/DC0%0/2
$answ and $answ =~ /<result code=['"](\d+)['"]>/
$answ $answ =~ /<result code=['"](\d+)['"]>/
Truth table0%0/3
A and B
A= $answB= $answ =~ /<result code=['"](\d+)['"]>/
ABresult
0X0
100
111
1131 0 my $rcode = $1 + 0;
1132  
1133 0 my $msg = '';
1134 0 ▶ if ( $answ =~ /<result.+<msg[^<>]*>(.+)<\/msg>.+\/result>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<result.+<msg[^<>]*>(.+)</msg>.+/result>]s) 0 0 0
1135 0 $msg = $1;
1136 }
1137  
1138 0 ▶ if ( $rcode != 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rcode != 1000) 0 0 0
1139 0 ▶ if ( $answ =~ /<reason>(.+)<\/reason>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<reason>(.+)</reason>]s) 0 0 0
1140 0 $msg .= '; ' . $1;
1141 }
1142  
1143 0 ▶ return wantarray ? ( 0, $rcode, $msg ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1144 }
1145  
1146 0 my $info = {};
1147  
1148 0 ▶ if ( $answ =~ /<resData>(.+)<\/resData>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<resData>(.+)</resData>]s) 0 0 0
1149 0 ▶ my $rdata = $1 // '';
Condition0%0/2
$1 // ""
l!l
00
MC/DC0%0/1
$1 // ""
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
1150  
1151 0 my @billing = $rdata =~ /(<billing:[^<>]+>[^<>]+<\/billing:[^<>]+>)/g;
1152  
1153 0 foreach my $row ( @billing ) {
1154 0 ▶ if ( $row =~ /<billing:([A-Za-z]+)\b[^<>]*>([^<>]+)<\/billing:[^<>]+>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row =~ m[<billing:([A-Za-z]+)\b[^<>]*>([^<>]+)</billing:[^<>]+>]) 0 0 0
1155 0 $info->{$1} = $2;
1156 }
1157 }
1158  
1159 0 $info->{calc_date} = delete $info->{calcDate};
1160 0 $info->{calc_date} =~ s/T/ /;
1161 0 $info->{calc_date} =~ s/\.\d+Z$//;
1162 }
1163  
1164 0 ▶ return wantarray ? ( $info, $rcode, $msg ) : $info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1165 }
1166  
1167 0 ▶ return wantarray ? ( 0, 0, 'empty answer' ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1168 }
1169  
1170  
1171 =head2 get_limits_info
1172  
1173 How many requests are left in this hour
1174  
1175 =cut
1176  
1177 sub get_limits_info {
1178 0 ▶ my ( $self ) = @_;
Subroutine get_limits_info: not called CC=13 SCAR=52.0
Pod documented
1179  
1180 0 my $cltrid = $self->get_cltrid();
1181  
1182 0 my $body = <<LIMINFO;
1183 $$self{urn}{head}
1184 <command>
1185 <info>
1186 <limits:info xmlns:limits="http://www.tcinet.ru/epp/tci-limits-1.0" xsi:schemaLocation="http://www.tcinet.ru/epp/tci-limits-1.0 tci-limits-1.0.xsd"/>
1187 </info>
1188 <clTRID>$cltrid</clTRID>
1189 </command>
1190 </epp>
1191 LIMINFO
1192  
1193 0 my $answ = $self->req( $body, 'limits_info' );
1194  
1195 0 ▶ if ( $answ && $answ =~ /<result code=['"](\d+)['"]>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ and $answ =~ /<result code=['"](\d+)['"]>/) 0 0 0
Condition0%0/3
$answ and $answ =~ /<result code=['"](\d+)['"]>/
!ll&&!rl&&r
000
MC/DC0%0/2
$answ and $answ =~ /<result code=['"](\d+)['"]>/
$answ $answ =~ /<result code=['"](\d+)['"]>/
Truth table0%0/3
A and B
A= $answB= $answ =~ /<result code=['"](\d+)['"]>/
ABresult
0X0
100
111
1196 0 my $rcode = $1 + 0;
1197  
1198 0 my $msg = '';
1199 0 ▶ if ( $answ =~ /<result.+<msg[^<>]*>(.+)<\/msg>.+\/result>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<result.+<msg[^<>]*>(.+)</msg>.+/result>]s) 0 0 0
1200 0 $msg = $1;
1201 }
1202  
1203 0 ▶ if ( $rcode != 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rcode != 1000) 0 0 0
1204 0 ▶ if ( $answ =~ /<reason>(.+)<\/reason>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<reason>(.+)</reason>]s) 0 0 0
1205 0 $msg .= '; ' . $1;
1206 }
1207  
1208 0 ▶ return wantarray ? ( 0, $rcode, $msg ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1209 }
1210  
1211 0 my $info = {};
1212  
1213 0 ▶ if ( $answ =~ /<resData>(.+)<\/resData>/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($answ =~ m[<resData>(.+)</resData>]s) 0 0 0
1214 0 ▶ my $rdata = $1 // '';
Condition0%0/2
$1 // ""
l!l
00
MC/DC0%0/1
$1 // ""
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
1215  
1216 0 my @limits = $rdata =~ /(<limits:[^<>]+>[^<>]+<\/limits:[^<>]+>)/g;
1217  
1218 0 foreach my $row ( @limits ) {
1219 0 ▶ if ( $row =~ /<limits:([^<>]+)>([^<>]+)<\/limits:[^<>]+>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row =~ m[<limits:([^<>]+)>([^<>]+)</limits:[^<>]+>]) 0 0 0
1220 0 $info->{$1} = $2;
1221 }
1222 }
1223 }
1224  
1225 0 ▶ return wantarray ? ( $info, $rcode, $msg ) : $info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1226 }
1227  
1228 0 ▶ return wantarray ? ( 0, 0, 'empty answer' ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1229 }
1230  
1231  
1232 =head2 get_stat_info
1233  
1234 Show domain statistics by metric
1235  
1236 key of params:
1237 C<metric> -- varians: C<domain>, C<domain_pending_transfer>, C<domain_pending_delete>, C<contact>, C<host>, C<all>
1238  
1239 Now not work:
1240  
1241 code="2400", msg="Command failed", reason="Internal server error"
1242  
1243 =cut
1244  
1245 sub get_stat_info {
1246 0 ▶ my ( $self, $params ) = @_;
Subroutine get_stat_info: not called CC=2 SCAR=17.9
Pod documented
1247  
1248 0 ▶ return ( 0, 0, 'no params' ) unless ref $params;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params 0 0 0
1249  
1250 0 my $cltrid = $self->get_cltrid();
1251  
1252 0 my $body = <<STATINFO;
1253 $$self{urn}{head}
1254 <command>
1255 <info>
1256 <stat:info xmlns:stat="http://www.tcinet.ru/epp/tci-stat-1.0">
1257 <stat:metric name="$$params{metric}"/>
1258 </stat:info>
1259 </info>
1260 <clTRID>$cltrid</clTRID>
1261 </command>
1262 </epp>
1263 STATINFO
1264  
1265 0 return $self->simple_request( $body, 'info' );
1266 }
1267  
1268  
1269 =head2 logout
1270  
1271 Close session, disconnect
1272  
1273 =cut
1274  
1275 sub logout {
1276 0 ▶ my ( $self ) = @_;
Subroutine logout: not called CC=4 SCAR=30.0
Pod documented
1277  
1278 0 ▶ return 0 unless $self && $self->{sock};
Branch: 1 branch
BranchTrueFalseTotal
unless $self and $self->{"sock"} 0 0 0
Condition0%0/3
$self and $self->{"sock"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self and $self->{"sock"}
$self $self->{"sock"}
Truth table0%0/3
A and B
A= $selfB= $self->{"sock"}
ABresult
0X0
100
111
1279  
1280 0 ▶ return 0 if $self->{alien};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"alien"} 0 0 0
1281  
1282 0 my $cltrid = $self->get_cltrid();
1283  
1284 0 my $body = <<LOGOUT;
1285 $$self{urn}{head}
1286 <command>
1287 <logout/>
1288 <clTRID>$cltrid</clTRID>
1289 </command>
1290 </epp>
1291 LOGOUT
1292  
1293 # The answer doesn't matter
1294 0 $self->req( $body, 'logout' );
1295  
1296 0 delete $$self{sock};
1297 0 delete $$self{cook};
1298 0 delete $$self{cookies};
1299 0 delete $$self{sessionid};
1300 0 delete $$self{user};
1301 0 delete $$self{url};
1302 }
1303  
1304 2 1;
1305  
1306  
1307 __END__
↑ Summary EPP/Base.pm »