DRI/Protocol/RRP.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DRI/Protocol/RRI.pm ↑ Summary DRI/Protocol/Whois.pm »
1 ## Domain Registry Interface, RRP Protocol
2 ##
3 ## Copyright (c) 2005,2008-2010,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::RRP;
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use base qw(Net::DRI::Protocol);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 use Net::DRI::Exception;
23 use Net::DRI::Util;
24  
25 use Net::DRI::Protocol::RRP::Message;
26 use Net::DRI::Protocol::RRP::Core::Status;
27  
28 use DateTime;
29 use DateTime::TimeZone;
30 use DateTime::Format::Strptime;
31  
32 =pod
33  
34 =head1 NAME
35  
36 Net::DRI::Protocol::RRP - RRP 1.1/2.0 Protocol for Net::DRI
37  
38 =head1 DESCRIPTION
39  
40 Please see the README file for details.
41  
42 =head1 SUPPORT
43  
44 For now, support questions should be sent to:
45  
46 E<lt>netdri@dotandco.comE<gt>
47  
48 Please also see the SUPPORT file in the distribution.
49  
50 =head1 SEE ALSO
51  
52 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
53  
54 =head1 AUTHOR
55  
56 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
57  
58 =head1 COPYRIGHT
59  
60 Copyright (c) 2005,2008-2010,2013-2014 Patrick Mevzek <netdri@dotandco.com>.
61 All rights reserved.
62  
63 This program is free software; you can redistribute it and/or modify
64 it under the terms of the GNU General Public License as published by
65 the Free Software Foundation; either version 2 of the License, or
66 (at your option) any later version.
67  
68 See the LICENSE file that comes with this distribution for more details.
69  
70 =cut
71  
72  
73 our %DATES=('registration expiration date' => 'exDate',
74 'created date' => 'crDate',
75 'updated date' => 'upDate',
76 'registrar transfer date' => 'trDate',
77 );
78  
79 our %IDS=('registrar' => 'clID',
80 'created by' => 'crID',
81 'updated by' => 'upID',
82 );
83  
84 ###############################################################################
85  
86 sub new
87 {
88 my ($c,$ctx,$rp)=@_;
89 my $drd=$ctx->{registry}->driver();
90 my $self=$c->SUPER::new($ctx);
91 $self->name('RRP');
92 my $version=Net::DRI::Util::check_equal($rp->{version},['1.1','2.0'],'2.0'); ## 1.1 (RFC #2832) or 2.0 (RFC #3632)
93 $self->version($version);
94 $self->capabilities('host_update','ip',['add','del']);
95 $self->capabilities('host_update','name',['set']);
96 $self->capabilities('domain_update','ns',['add','del']);
97 $self->capabilities('domain_update','status',['add','del']);
98 $self->factories('message',sub { my $m=Net::DRI::Protocol::RRP::Message->new(@_); $m->version($version); return $m; });
99 $self->factories('status',sub { return Net::DRI::Protocol::RRP::Core::Status->new(); });
100  
101 ## Verify that we have the timezone of the registry, since dates in RRP are local to registries
102 my $tzname=$drd->info('tz');
103 Net::DRI::Exception::usererr_insufficient_parameters('no registry timezone') unless (defined($tzname));
104 my $tz;
105 eval { $tz=DateTime::TimeZone->new(name => $tzname); };
106 Net::DRI::Exception::usererr_invalid_parameters("invalid registry timezone ($tzname), unable to instantiate") unless (defined $tz && ref $tz);
107 my $dtp;
108 eval { $dtp=DateTime::Format::Strptime->new(time_zone=>$tz, pattern=>'%Y-%m-%d %H:%M:%S.0'); };
109 Net::DRI::Exception::usererr_invalid_parameters("invalid registry timezone ($tzname), unable to create parser") unless (defined $dtp && ref $dtp);
110 $self->{dt_parse}=$dtp;
111  
112 $self->_load($rp);
113 return $self;
114 }
115  
116 my $BASE = 'Net::DRI::Protocol::RRP::Core::';
117  
118 sub _load
119 {
120 my ($self,$rp)=@_;
121 my $extramods=$rp->{extensions};
122 my @class=map { $BASE.$_ } qw/Session Domain Host/;
123 push @class,map { my $f=$_; if ($f=~m/^([^+])(.+)$/) { $f = $1 eq '-' ? '-'.$BASE.$2 : $BASE.$1.$2; } $f; } (ref $extramods ? @$extramods : ($extramods)) if defined $extramods && $extramods;
124  
125 return $self->SUPER::_load(@class);
126 }
127  
128 sub transport_default
129 {
130 my ($self)=@_;
131 return (protocol_connection => 'Net::DRI::Protocol::RRP::Connection', protocol_version => 1);
132 }
133  
134 ###############################################################################################
135 1;
« DRI/Protocol/RRI.pm ↑ Summary DRI/Protocol/Whois.pm »