| 1 | ## Domain Registry Interface, Main entry point | ||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2005-2016,2018-2019 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; | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 84 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 84 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 84 | ▶ | use Net::DRI::Cache; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 84 | ▶ | use Net::DRI::Registry; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 84 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 84 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 84 | ▶ | use base qw(Class::Accessor::Chained::Fast Net::DRI::BaseClass); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 84 | __PACKAGE__->mk_ro_accessors(qw/trid_factory logging cache/); | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 84 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 29 | 84 | our $VERSION='0.96_13'; | |||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | =pod | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | Net::DRI - Interface to Domain Name Registries/Registrars/Resellers | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | This documentation refers to Net::DRI version 0.96_12 | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | use Net::DRI; | ||||||||||||||||||||||||||||||||
| 44 | my $dri=Net::DRI->new({ cache_ttl => 10, trid_factory => ..., logging => .... }); | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | ... various operations ... | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | $dri->end(); | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | Net::DRI is a Perl library to access services offered by domain name | ||||||||||||||||||||||||||||||||
| 53 | providers, such as registries or registrars. DRI stands for | ||||||||||||||||||||||||||||||||
| 54 | Domain Registration Interface and it aims to be | ||||||||||||||||||||||||||||||||
| 55 | for domain name registries/registrars/resellers what DBI is for databases: | ||||||||||||||||||||||||||||||||
| 56 | an abstraction over multiple providers, with multiple policies, transports | ||||||||||||||||||||||||||||||||
| 57 | and protocols all used through a uniform API. | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | It is an object-oriented framework implementing RRP (RFC 2832/3632), | ||||||||||||||||||||||||||||||||
| 60 | EPP (core EPP in RFC 5730/5731/5732/5733/5734 aka STD69, extensions in | ||||||||||||||||||||||||||||||||
| 61 | RFC 3915/4114/4310/5076 and various extensions of ccTLDs/gTLDs | ||||||||||||||||||||||||||||||||
| 62 | - currently more than 60 TLDs are directly supported with extensions), | ||||||||||||||||||||||||||||||||
| 63 | RRI (.DE registration protocol), Whois, DAS (Domain Availability Service used by .BE, .EU, .AU, .NL), | ||||||||||||||||||||||||||||||||
| 64 | IRIS (RFC3981) DCHK (RFC5144) over LWZ (RFC4993) for .DE currently and XCP (RFC4992), | ||||||||||||||||||||||||||||||||
| 65 | .FR/.RE email and webservices interface, and resellers interface of some registrars | ||||||||||||||||||||||||||||||||
| 66 | (Gandi, OpenSRS, etc.). | ||||||||||||||||||||||||||||||||
| 67 | It has transports for connecting with UDP/TCP/TLS, HTTP/HTTPS, | ||||||||||||||||||||||||||||||||
| 68 | Web Services (XML-RPC and SOAP with/without WSDL), | ||||||||||||||||||||||||||||||||
| 69 | or SMTP-based registries/registrars. | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | It is not limited to handling of domain names, it can be easily extended. | ||||||||||||||||||||||||||||||||
| 72 | For example, it supports ENUM registrations and validations, or DNSSEC provisioning. | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | A shell is included for easy prototyping and debugging, see L<Net::DRI::Shell>. | ||||||||||||||||||||||||||||||||
| 75 | Caching and logging features are also included by default. | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | Please see the included README file for full details. | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | Please see the C<eg/> subdirectory of the distribution, it contains various | ||||||||||||||||||||||||||||||||
| 82 | examples. Please also see all unit tests under C<t/>, they show all parts of the API. | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | After having used Net::DRI (which is the only module you should need to C<use> from | ||||||||||||||||||||||||||||||||
| 87 | this distribution), you create an object as instance of this class, | ||||||||||||||||||||||||||||||||
| 88 | and every operation will be carried through it. | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | =head2 trid_factory() | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | This is an accessor to the trid factory (code reference) used to generate client | ||||||||||||||||||||||||||||||||
| 93 | transaction identificators, that are useful for logging and asynchronous operations. | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | During the C<new()> call, a C<trid_factory()> is initialized to a default safe value | ||||||||||||||||||||||||||||||||
| 96 | (being Net::DRI::Util::create_trid_1). | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | You need to call this method only if you wish to use another function to generate transaction identificators. | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | All other objects (registry profiles and transports) | ||||||||||||||||||||||||||||||||
| 101 | created after that will inherit this value. If you call again C<trid_factory()> | ||||||||||||||||||||||||||||||||
| 102 | the change will only apply to new objects (registry profiles and transports) created after the change, | ||||||||||||||||||||||||||||||||
| 103 | it will not apply to already existing objects (registry profiles and transports). | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | =head2 logging() | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | This is an accessor to the underlying Logging object. During the C<new()> call you can | ||||||||||||||||||||||||||||||||
| 108 | provide the object, or just a string ("null", "stderr", "files" or "syslog" which are the | ||||||||||||||||||||||||||||||||
| 109 | current logging modules available in Net::DRI), or a reference to an array | ||||||||||||||||||||||||||||||||
| 110 | with the first parameter a string (same as previously) and the second parameter a reference to | ||||||||||||||||||||||||||||||||
| 111 | an hash with data needed by the logging class used (see for example L<Net::DRI::Logging::Files>). | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | If you want to log the application data (what is exchanged with remote server, such as EPP XML streams), | ||||||||||||||||||||||||||||||||
| 114 | you need to use logging level of 'notice', or higher. | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | =head2 cache() | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | This is an accessor to the underlying Cache object. See L<Net::DRI::Cache>. | ||||||||||||||||||||||||||||||||
| 119 | This object has a C<ttl()> method to access and change the current time to live | ||||||||||||||||||||||||||||||||
| 120 | for cached data. | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | L<http://www.dotandco.com/services/software/Net-DRI/> | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||||||
| 137 | and various contributors (see Changes file and web page above) | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | Copyright (c) 2005-2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||||||
| 142 | All rights reserved. | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | =head1 LICENSE | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||
| 147 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||
| 148 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||
| 149 | (at your option) any later version. | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | sub new | ||||||||||||||||||||||||||||||||
| 158 | 77 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 159 | 77 | my ($class,$rh)=@_; | |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | my $self={ cache => Net::DRI::Cache->new(Net::DRI::Util::has_key($rh,'cache_ttl') ? $rh->{cache_ttl} : 0), | ||||||||||||||||||||||||||||||||
| 162 | current_registry => undef, ## registry name (key of following hash) | ||||||||||||||||||||||||||||||||
| 163 | registries => {}, ## registry name => Net::DRI::Registry object | ||||||||||||||||||||||||||||||||
| 164 | tlds => {}, ## tld => [ registries name ] | ||||||||||||||||||||||||||||||||
| 165 | time_created => time(), | ||||||||||||||||||||||||||||||||
| 166 | 77 | ▶ | trid_factory => (Net::DRI::Util::has_key($rh,'trid_factory') && ref $rh->{trid_factory} eq 'CODE')? $rh->{trid_factory} : \&Net::DRI::Util::create_trid_1, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
Net::DRI::Util::has_key($rh, "trid_factory") and ref $rh->{"trid_factory"} eq "CODE"
MC/DC50%1/2
Net::DRI::Util::has_key($rh, "trid_factory") and ref $rh->{"trid_factory"} eq "CODE"
Net::DRI::Util::has_key($rh, "trid_factory")
ref $rh->{"trid_factory"} eq "CODE"
Truth table66%2/3
A and B
A= Net::DRI::Util::has_key($rh, "trid_factory")B= ref $rh->{"trid_factory"} eq "CODE"
| |||||||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 77 | my ($logname,@logdata); | |||||||||||||||||||||||||||||||
| 170 | 77 | ▶ | if (Net::DRI::Util::has_key($rh,'logging')) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | ($logname,@logdata)=ref $rh->{logging} eq 'ARRAY' ? @{$rh->{logging}} : ($rh->{logging}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | } else | ||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||
| 175 | 73 | $logname='null'; | |||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | 77 | ▶ | if ($logname !~ s/^\+//) { $logname='Net::DRI::Logging::'.ucfirst($logname); } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 178 | 77 | Net::DRI::Util::load_module($logname,'DRI'); | |||||||||||||||||||||||||||||||
| 179 | 77 | $self->{logging}=$logname->new(@logdata); | |||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | 77 | bless($self,$class); | |||||||||||||||||||||||||||||||
| 182 | 77 | $self->logging()->setup_channel(__PACKAGE__,'core'); | |||||||||||||||||||||||||||||||
| 183 | 77 | $self->log_output('notice','core','Successfully created Net::DRI object with logging='.$logname); | |||||||||||||||||||||||||||||||
| 184 | 77 | return $self; | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | sub add_current_registry | ||||||||||||||||||||||||||||||||
| 188 | 46 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_current_registry: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 189 | 46 | my ($self,@p)=@_; | |||||||||||||||||||||||||||||||
| 190 | 46 | $self->add_registry(@p); | |||||||||||||||||||||||||||||||
| 191 | 46 | $self->target($self->{last_registry}); | |||||||||||||||||||||||||||||||
| 192 | 46 | return $self; | |||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | sub add_registry | ||||||||||||||||||||||||||||||||
| 196 | 77 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_registry: called CC=11 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 197 | 77 | my ($self,$reg,@data)=@_; | |||||||||||||||||||||||||||||||
| 198 | 77 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('add_registry needs a registry name') unless Net::DRI::Util::all_valid($reg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | 77 | ▶ | $reg='Net::DRI::DRD::'.$reg unless $reg=~m/^\+/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | 77 | Net::DRI::Util::load_module($reg,'DRI'); | |||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 77 | my $drd=$reg->new(@data); | |||||||||||||||||||||||||||||||
| 203 | 77 | ▶ | Net::DRI::Exception->die(1,'DRI',9,'Failed to initialize registry '.$reg) unless ($drd && ref $drd); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$drd and ref $drd
MC/DC0%0/2
$drd and ref $drd
$drd
ref $drd
Truth table33%1/3
A and B
A= $drdB= ref $drd
| |||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | 77 | ▶ | Net::DRI::Exception::method_not_implemented('name',$reg) unless $drd->can('name'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 77 | my $regname=$drd->name(); | |||||||||||||||||||||||||||||||
| 207 | 77 | ▶ | Net::DRI::Exception->die(1,'DRI',10,'No dot allowed in registry name: '.$regname) unless index($regname,'.') == -1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 208 | 77 | ▶ | Net::DRI::Exception->die(1,'DRI',11,'New registry name already in use') if exists $self->{registries}->{$regname}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | 77 | my $ndr=Net::DRI::Registry->new($regname,$drd,$self->{cache},$self->{trid_factory},$self->{logging}); | |||||||||||||||||||||||||||||||
| 211 | 77 | ▶ | Net::DRI::Exception::method_not_implemented('tlds',$reg) unless $drd->can('tlds'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 77 | foreach my $tld ($drd->tlds()) | |||||||||||||||||||||||||||||||
| 213 | { | ||||||||||||||||||||||||||||||||
| 214 | 478 | $tld=lc($tld); | |||||||||||||||||||||||||||||||
| 215 | 478 | ▶ | $self->{tlds}->{$tld}=[] unless exists $self->{tlds}->{$tld}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 216 | 478 | push @{$self->{tlds}->{$tld}},$regname; | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 77 | $self->log_output('notice','core','Successfully added registry "'.$regname.'"'); | |||||||||||||||||||||||||||||||
| 220 | 77 | $self->{registries}->{$regname}=$ndr; | |||||||||||||||||||||||||||||||
| 221 | 77 | $self->{last_registry}=$regname; | |||||||||||||||||||||||||||||||
| 222 | 77 | return $self; | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | sub del_registry | ||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
del_registry: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 227 | 0 | my ($self,$name)=@_; | |||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (defined $name) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | err_registry_name_does_not_exist($name) unless exists $self->{registries}->{$name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 231 | } else | ||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | err_no_current_registry() unless defined $self->{current_registry}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | 0 | $name=$self->{current_registry}; | |||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||
| 236 | 0 | $self->{registries}->{$name}->end(); | |||||||||||||||||||||||||||||||
| 237 | 0 | delete($self->{registries}->{$name}); | |||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $self->{current_registry}=undef if $self->{current_registry} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 239 | 0 | $self->log_output('notice','core','Successfully deleted registry "'.$name.'"'); | |||||||||||||||||||||||||||||||
| 240 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||
| 243 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub err_no_current_registry { Net::DRI::Exception->die(0,'DRI',1,'No current registry available'); } ## no critic (Subroutines::RequireArgUnpacking Subroutines::RequireFinalReturn) | ||||||||||||||||||||||||||||||
|
Subroutine
err_no_current_registry: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub err_registry_name_does_not_exist { Net::DRI::Exception->die(0,'DRI',2,'Registry name '.$_[0].' does not exist'); } ## no critic (Subroutines::RequireArgUnpacking Subroutines::RequireFinalReturn) | ||||||||||||||||||||||||||||||
|
Subroutine
err_registry_name_does_not_exist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 249 | ## Accessor functions | ||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub available_registries { my ($self)=@_; my @r=sort { $a cmp $b } keys %{$self->{registries}}; return @r; } | ||||||||||||||||||||||||||||||
|
Subroutine
available_registries: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 252 | sub available_registries_profiles | ||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
available_registries_profiles: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 254 | 0 | my ($self,$full)=@_; | |||||||||||||||||||||||||||||||
| 255 | 0 | my %r; | |||||||||||||||||||||||||||||||
| 256 | 0 | foreach my $reg (keys(%{$self->{registries}})) | |||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||
| 258 | 0 | $r{$reg}=[ $self->{registries}->{$reg}->available_profiles($full) ]; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | 0 | return \%r; | |||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | 81 | ▶ | sub registry_name { return shift->{current_registry}; } | ||||||||||||||||||||||||||||||
|
Subroutine
registry_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | sub registry | ||||||||||||||||||||||||||||||||
| 265 | 81 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
registry: called CC=5 SCAR=17.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 266 | 81 | my ($self)=@_; | |||||||||||||||||||||||||||||||
| 267 | 81 | my $regname=$self->registry_name(); | |||||||||||||||||||||||||||||||
| 268 | 81 | ▶ | err_no_current_registry() unless (defined($regname) && $regname); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $regname and $regname
MC/DC0%0/2
defined $regname and $regname
defined $regname
$regname
Truth table33%1/3
A and B
A= defined $regnameB= $regname
| |||||||||||||||||||||||||||||||||
| 269 | 81 | ▶ | err_registry_name_does_not_exist($regname) unless (exists($self->{registries}->{$regname})); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 270 | 81 | my $ndr=$self->{registries}->{$regname}; | |||||||||||||||||||||||||||||||
| 271 | 81 | ▶ | return wantarray? ($regname,$ndr) : $ndr; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | sub tld2reg | ||||||||||||||||||||||||||||||||
| 275 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
tld2reg: called CC=5 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 276 | 1 | my ($self,$tld)=@_; | |||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | return unless defined($tld) && $tld; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $tld and $tld
MC/DC0%0/2
defined $tld and $tld
defined $tld
$tld
Truth table33%1/3
A and B
A= defined $tldB= $tld
| |||||||||||||||||||||||||||||||||
| 278 | 1 | $tld=lc($tld); | |||||||||||||||||||||||||||||||
| 279 | 1 | ▶ | $tld=$1 if ($tld=~m/\.([a-z0-9]+)$/); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 280 | 1 | ▶ | return unless exists($self->{tlds}->{$tld}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 281 | 1 | my @t=@{$self->{tlds}->{$tld}}; | |||||||||||||||||||||||||||||||
| 282 | 1 | return @t; | |||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | sub installed_registries | ||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
installed_registries: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 287 | 0 | return qw/AdamsNames Afilias AFNIC ARNES auDA BelizeNIC BookMyName CentralNic CGIBR CIRA CoCCA CZNIC Datacom DENIC DNSBelgium DNSPT doMEn Domicilium DotAsia DotCooperation dotMOBI EURid Gandi GDI ICMRegistry IENUMAT IRegistry ISPAPI IIS IITCNR IUSN NASK Neustar::BIZ Neustar::US NicAT NicLC Nominet NORID OpenSRS OVH PANDI PIR puntCAT RDS RegistryPro RESTENA SaintVincentGrenadines SIDN SITA SONIC SWITCH TCI TELEGreenland Telnic TRA Tralliance UHSA UPU VCS VeriSign::COM_NET VeriSign::NAME VeriSign::NameStore ZACR/; | |||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | sub target | ||||||||||||||||||||||||||||||||
| 293 | 77 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=8 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 294 | 77 | my ($self,$driver,$profile)=@_; | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | ## Try to convert if given a domain name or a tld instead of a driver's name | ||||||||||||||||||||||||||||||||
| 297 | 77 | ▶ | if (defined $driver && ! exists $self->{registries}->{$driver}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $driver and not exists $self->{"registries"}{$driver}
MC/DC50%1/2
defined $driver and not exists $self->{"registries"}{$driver}
defined $driver
not exists $self->{"registries"}{$driver}
Truth table66%2/3
A and not(B)
A= defined $driverB= not exists $self->{"registries"}{$driver}
| |||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||
| 299 | 1 | my @t=$self->tld2reg($driver); | |||||||||||||||||||||||||||||||
| 300 | 1 | ▶ | Net::DRI::Exception->die(0,'DRI',7,'Registry not found for domain name/TLD '.$driver) unless (@t==1); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 1 | $driver=$t[0]; | |||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | 77 | ▶ | $driver=$self->registry_name() unless defined $driver; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 305 | 77 | ▶ | err_registry_name_does_not_exist($driver) unless defined $driver && $driver; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $driver and $driver
MC/DC0%0/2
defined $driver and $driver
defined $driver
$driver
Truth table33%1/3
A and B
A= defined $driverB= $driver
| |||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | 77 | ▶ | if (defined $profile) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||
| 309 | 0 | $self->{registries}->{$driver}->target($profile); | |||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | 77 | $self->{current_registry}=$driver; | |||||||||||||||||||||||||||||||
| 313 | 77 | return $self; | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 317 | ## The meat of everything | ||||||||||||||||||||||||||||||||
| 318 | ## See Cookbook, page 468 | ||||||||||||||||||||||||||||||||
| 319 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||
| 320 | 81 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||
| 321 | 81 | my ($self,@args)=@_; | |||||||||||||||||||||||||||||||
| 322 | 81 | my $attr=$AUTOLOAD; | |||||||||||||||||||||||||||||||
| 323 | 81 | $attr=~s/.*:://; | |||||||||||||||||||||||||||||||
| 324 | 81 | ▶ | return unless $attr=~m/[^A-Z]/; ## skip DESTROY and all-cap methods | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | 81 | my ($name,$ndr)=$self->registry(); | |||||||||||||||||||||||||||||||
| 327 | 81 | ▶ | Net::DRI::Exception::method_not_implemented($attr,$ndr) unless ref $ndr && $ndr->can($attr); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $ndr and $ndr->can($attr)
MC/DC0%0/2
ref $ndr and $ndr->can($attr)
ref $ndr
$ndr->can($attr)
Truth table33%1/3
A and B
A= ref $ndrB= $ndr->can($attr)
| |||||||||||||||||||||||||||||||||
| 328 | 81 | $self->log_output('debug','core','Calling '.$attr.' from Net::DRI'); | |||||||||||||||||||||||||||||||
| 329 | 81 | return $ndr->$attr(@args); ## is goto beter here ? | |||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | sub end | ||||||||||||||||||||||||||||||||
| 333 | 77 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
end: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 334 | 77 | my $self=shift; | |||||||||||||||||||||||||||||||
| 335 | 77 | ▶ | while(my ($name,$v)=each(%{$self->{registries}})) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||
| 337 | 77 | ▶ | $v->end() if (ref($v) && $v->can('end')); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $v and $v->can("end")
MC/DC0%0/2
ref $v and $v->can("end")
ref $v
$v->can("end")
Truth table33%1/3
A and B
A= ref $vB= $v->can("end")
| |||||||||||||||||||||||||||||||||
| 338 | 77 | $self->log_output('notice','core','Successfully ended registry "'.$name.'"'); | |||||||||||||||||||||||||||||||
| 339 | 77 | $v={}; | |||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||
| 341 | 77 | $self->{tlds}={}; | |||||||||||||||||||||||||||||||
| 342 | 77 | $self->{registries}={}; | |||||||||||||||||||||||||||||||
| 343 | 77 | $self->{current_registry}=undef; | |||||||||||||||||||||||||||||||
| 344 | 77 | ▶ | if (defined $self->{logging}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||
| 346 | 77 | $self->log_output('notice','core','Successfully ended Net::DRI object'); | |||||||||||||||||||||||||||||||
| 347 | 77 | $self->{logging}=undef; | |||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||
| 350 | 77 | return 1; ## this makes it easy to test if everything before was ok or not, if we are inside an eval {} and $dri->end() is the last operation inside the eval block | |||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 77 | ▶ | sub DESTROY { my $self=shift; return $self->end(); } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | package Net::DRI::TrapExceptions; ## no critic (Modules::ProhibitMultiplePackages) | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | 84 | ▶ | use base qw/Net::DRI/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | 84 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | ## Some methods may die in Net::DRI, we specifically trap them | ||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub add_registry { my ($self,@p)=@_; my $r; my $ok=eval { $r=$self->SUPER::add_registry(@p); 1; }; return $r if $ok; die(ref $@ ? $@->as_string() : $@); } | ||||||||||||||||||||||||||||||
|
Subroutine
add_registry: called CC=3 SCAR=12.3
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub del_registry { my ($self,@p)=@_; my $r; my $ok=eval { $r=$self->SUPER::del_registry(@p); 1; }; return $r if $ok; die(ref $@ ? $@->as_string() : $@); } | ||||||||||||||||||||||||||||||
|
Subroutine
del_registry: not called CC=3 SCAR=24.8
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub registry { my ($self,@p)=@_; my @r; my $ok=eval { @r=$self->SUPER::registry(@p); 1; }; if ($ok) { return wantarray ? @r : $r[0]; } die(ref $@ ? $@->as_string() : $@); } | ||||||||||||||||||||||||||||||
|
Subroutine
registry: called CC=4 SCAR=15.5
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub target { my ($self,@p)=@_; my $r; my $ok=eval { $r=$self->SUPER::target(@p); 1; }; return $r if $ok; die(ref $@ ? $@->as_string() : $@); } | ||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=3 SCAR=12.3
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | sub end { my ($self,@p)=@_; my $r; my $ok=eval { $r=$self->SUPER::end(@p); 1; }; return $r if $ok; die(ref $@ ? $@->as_string() : $@); } | ||||||||||||||||||||||||||||||
|
Subroutine
end: called CC=3 SCAR=12.3
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||
| 371 | 67 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=15.8
| |||||||||||||||||||||||||||||||||
| 372 | 67 | my $self=shift; | |||||||||||||||||||||||||||||||
| 373 | 67 | my @r; | |||||||||||||||||||||||||||||||
| 374 | 67 | $Net::DRI::AUTOLOAD=$AUTOLOAD; | |||||||||||||||||||||||||||||||
| 375 | 0 | my $ok=eval { @r=$self->SUPER::AUTOLOAD(@_); 1; }; | |||||||||||||||||||||||||||||||
| 376 | 67 | ▶ | if (! $ok) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||
| 378 | 67 | my $err=$@; | |||||||||||||||||||||||||||||||
| 379 | 67 | ▶ | die(ref $err ? $err->as_string() : $err); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | return wantarray ? @r : $r[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||
| 384 | #################################################################################################### | ||||||||||||||||||||||||||||||||
| 385 | 84 | 1; | |||||||||||||||||||||||||||||||