| 1 | ## Domain Registry Interface, RRI Connection handling | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2007-2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>. 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::RRI::Connection; | ||||||||||||||||||||||||||||
| 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::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Data::Raw; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Net::DRI::Protocol::ResultStatus; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =pod | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 NAME | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | Net::DRI::Protocol::RRI::Connection - RRI Connection handling (DENIC-11) for Net::DRI | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | E<lt>tonnerre.lombard@sygroup.chE<gt> | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | E<lt>http://oss.bsdprojects.net/projects/netdri/E<gt> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Tonnerre Lombard, E<lt>tonnerre.lombard@sygroup.chE<gt> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Copyright (c) 2007-2009,2013 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>. | ||||||||||||||||||||||||||||
| 53 | All rights reserved. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 56 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 57 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 58 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | #################################################################################################### | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub login | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
login: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | my ($class, $cm, $id, $pass, $cltrid, $dr, $newpass, $pdata) = @_; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my $mes=$cm->(); | |||||||||||||||||||||||||||
| 71 | 0 | $mes->command(['login']); | |||||||||||||||||||||||||||
| 72 | 0 | my @d; | |||||||||||||||||||||||||||
| 73 | 0 | push @d,['user',$id]; | |||||||||||||||||||||||||||
| 74 | 0 | push @d,['password',$pass]; | |||||||||||||||||||||||||||
| 75 | 0 | $mes->command_body(\@d); | |||||||||||||||||||||||||||
| 76 | 0 | return $mes; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub logout | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
logout: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my ($class,$cm,$cltrid)=@_; | |||||||||||||||||||||||||||
| 82 | 0 | my $mes=$cm->(); | |||||||||||||||||||||||||||
| 83 | 0 | $mes->command(['logout']); | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | $mes->cltrid($cltrid) if $cltrid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | return $mes; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub keepalive | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
keepalive: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my ($class,$cm,$cltrid)=@_; | |||||||||||||||||||||||||||
| 91 | 0 | my $mes=$cm->(); | |||||||||||||||||||||||||||
| 92 | 0 | $mes->command(['hello']); | |||||||||||||||||||||||||||
| 93 | 0 | return $mes; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #################################################################################################### | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | sub read_data | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
read_data: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 0 | my ($class,$to,$sock)=@_; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | my $version = $to->{transport}->{protocol_version}; | |||||||||||||||||||||||||||
| 103 | 0 | my $m=''; | |||||||||||||||||||||||||||
| 104 | 0 | my $c; | |||||||||||||||||||||||||||
| 105 | 0 | my $rl=$sock->sysread($c, 4); ## first 4 bytes are the packed length | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_FAILED_CLOSING', | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rl and $rl == 4
MC/DC0%0/2
defined $rl and $rl == 4
defined $rl
$rl == 4
Truth table0%0/3
A and B
A= defined $rlB= $rl == 4
| |||||||||||||||||||||||||||||
| 107 | 'Unable to read RRI 4 bytes length (connection closed by registry ?): '.$!, | ||||||||||||||||||||||||||||
| 108 | 'en')) unless (defined $rl && $rl==4); | ||||||||||||||||||||||||||||
| 109 | 0 | my $length = unpack('N', $c); | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | while ($length > 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | 0 | my $new; | |||||||||||||||||||||||||||
| 113 | 0 | $length-=$sock->sysread($new,$length); | |||||||||||||||||||||||||||
| 114 | 0 | $m.=$new; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | $m=Net::DRI::Util::decode_utf8($m); | |||||||||||||||||||||||||||
| 118 | 0 | ▶ | die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR', | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 119 | $m ? $m : '<empty message from server>', 'en')) | ||||||||||||||||||||||||||||
| 120 | unless ($m =~ m!</registry-response>$!); | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | return Net::DRI::Data::Raw->new_from_xmlstring($m); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | sub write_message | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
write_message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 0 | my ($self,$to,$msg)=@_; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $m=Net::DRI::Util::encode_utf8($msg->as_string()); | |||||||||||||||||||||||||||
| 130 | 0 | my $l = pack('N', length($m)); ## DENIC-11 | |||||||||||||||||||||||||||
| 131 | 0 | return $l.$m; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | sub parse_login | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
parse_login: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 136 | 0 | my ($class,$dc)=@_; | |||||||||||||||||||||||||||
| 137 | 0 | my ($result,$code,$msg)=find_result($dc); | |||||||||||||||||||||||||||
| 138 | 0 | ▶ | unless (defined($result) && ($result eq 'success')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and $result eq "success"
MC/DC0%0/2
defined $result and $result eq "success"
defined $result
$result eq "success"
Truth table0%0/3
A and B
A= defined $resultB= $result eq "success"
| |||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR', | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $msg and length $msg
MC/DC0%0/2
defined $msg and length $msg
defined $msg
length $msg
Truth table0%0/3
A and B
A= defined $msgB= length $msg
| |||||||||||||||||||||||||||||
| 141 | (defined($msg) && length($msg) ? $msg : 'Login failed'), 'en'); | ||||||||||||||||||||||||||||
| 142 | } else | ||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | 0 | return Net::DRI::Protocol::ResultStatus->new_success('COMMAND_SUCCESSFUL', | |||||||||||||||||||||||||||
| 145 | 'Login OK', 'en'); | ||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | sub parse_logout | ||||||||||||||||||||||||||||
| 150 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
parse_logout: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | 0 | my ($class,$dc)=@_; | |||||||||||||||||||||||||||
| 152 | 0 | my ($result,$code,$msg)=find_result($dc); | |||||||||||||||||||||||||||
| 153 | 0 | ▶ | unless (defined($result) && ($result eq 'success')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and $result eq "success"
MC/DC0%0/2
defined $result and $result eq "success"
defined $result
$result eq "success"
Truth table0%0/3
A and B
A= defined $resultB= $result eq "success"
| |||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR', | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $msg and length $msg
MC/DC0%0/2
defined $msg and length $msg
defined $msg
length $msg
Truth table0%0/3
A and B
A= defined $msgB= length $msg
| |||||||||||||||||||||||||||||
| 156 | (defined($msg) && length($msg) ? $msg : 'Logout failed'), 'en'); | ||||||||||||||||||||||||||||
| 157 | } else | ||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||
| 159 | 0 | return Net::DRI::Protocol::ResultStatus->new_success('COMMAND_SUCCESSFUL', | |||||||||||||||||||||||||||
| 160 | 'Logout OK', 'en'); | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | sub find_result | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
find_result: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $dc=shift; | |||||||||||||||||||||||||||
| 167 | 0 | my $a=$dc->as_string(); | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | return () unless ($a=~m!</registry-response>!); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | $a=~s/>[\n\s\t]+/>/g; | |||||||||||||||||||||||||||
| 170 | 0 | my ($result,$code,$msg); | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | return () unless (($result)=($a=~m!<tr:result>(\w+)</tr:result>!)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | ($code) = ($a =~ m!<tr:message.*code="(\d+)">!); | |||||||||||||||||||||||||||
| 173 | 0 | ($msg) = ($a =~ m!<tr:text>([^>]+)</tr:text>!); | |||||||||||||||||||||||||||
| 174 | 0 | return ($result, $code, $msg); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | sub transport_default | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
transport_default: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 179 | 0 | my ($self,$tname)=@_; | |||||||||||||||||||||||||||
| 180 | 0 | return (); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | #################################################################################################### | ||||||||||||||||||||||||||||
| 184 | 1 | 1; | |||||||||||||||||||||||||||