| 1 | ## Domain Registry Interface, VeriSign Zone Management EPP extension | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2012,2015,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::Protocol::EPP::Extensions::VeriSign::ZoneManagement; | ||||||||||||||||||||||||||||
| 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::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #################################################################################################### | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub register_commands | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($class,$version)=@_; | |||||||||||||||||||||||||||
| 28 | 0 | return { 'domain' => { create => [ \&domain_create_generate, undef ], | |||||||||||||||||||||||||||
| 29 | info => [ undef, \&domain_info_parse ], | ||||||||||||||||||||||||||||
| 30 | update => [ \&domain_update_generate, undef ] }, | ||||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub setup | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($class,$po,$version)=@_; | |||||||||||||||||||||||||||
| 37 | 0 | $po->ns({ 'zoneMgt' => 'http://www.verisign.com/epp/zoneMgt-1.0', | |||||||||||||||||||||||||||
| 38 | }); | ||||||||||||||||||||||||||||
| 39 | 0 | return; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | #################################################################################################### | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub _generate_rrecs | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_generate_rrecs: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||
| 46 | 0 | my ($rr)=@_; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | my @d=ref $rr eq 'ARRAY' ? @$rr : ($rr); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('RRs must be array of ref hashes') if grep { ref $_ ne 'HASH' } @d; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | my @r; | |||||||||||||||||||||||||||
| 51 | 0 | foreach my $r (@d) | |||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||
| 53 | 0 | my @rr; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('In RR, "type" key must exist') unless Net::DRI::Util::has_key($r,'type'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "type", value must be an XML token') unless Net::DRI::Util::xml_is_token($r->{type}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | push @rr,['zoneMgt:type',$r->{type}]; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (Net::DRI::Util::has_key($r,'class')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "class", value must be an XML token, if provided') unless Net::DRI::Util::xml_is_token($r->{class}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | push @rr,['zoneMgt:class',$r->{class}]; | |||||||||||||||||||||||||||
| 61 | } else | ||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 0 | push @rr,['zoneMgt:class','IN']; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if (Net::DRI::Util::has_key($r,'ttl')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "ttl", value must be an XML integeter, if provided') unless Net::DRI::Util::verify_int($r->{ttl}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | push @rr,['zoneMgt:ttl',$r->{ttl}]; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | Net::DRI::Exception::usererr_insufficient_parameters('In RR, "rdata" key must exist') unless Net::DRI::Util::has_key($r,'rdata'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "rdata", value must be an XML token') unless Net::DRI::Util::xml_is_token($r->{rdata}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | push @rr,['zoneMgt:rdata',$r->{rdata}]; | |||||||||||||||||||||||||||
| 73 | 0 | push @r,['zoneMgt:rrec',@rr]; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | return @r; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | sub domain_create_generate | ||||||||||||||||||||||||||||
| 79 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
domain_create_generate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 0 | my ($epp,$domain,$rp)=@_; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return unless Net::DRI::Util::has_key($rp,'zone'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | $epp->message()->command_extension('zoneMgt', ['create', _generate_rrecs($rp->{zone})]); | |||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub domain_info_parse | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
domain_info_parse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 91 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | my $data=$mes->get_response('zoneMgt','infData'); | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my @r; | |||||||||||||||||||||||||||
| 98 | 0 | foreach my $el (Net::DRI::Util::xml_list_children($data)) | |||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||
| 100 | 0 | my ($name,$c)=@$el; | |||||||||||||||||||||||||||
| 101 | 0 | my %r; | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ($name eq 'rrec') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||
| 104 | 0 | foreach my $subel (Net::DRI::Util::xml_list_children($c)) | |||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||
| 106 | 0 | my ($subname,$subc)=@$subel; | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($subname=~m/^(type|class|ttl|rdata)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||
| 109 | 0 | $r{$1}=$subc->textContent(); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 0 | push @r,\%r; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | $rinfo->{domain}->{$oname}->{zone}=\@r; | |||||||||||||||||||||||||||
| 117 | 0 | return; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub domain_update_generate | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
domain_update_generate: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | 0 | my ($epp,$domain,$todo,$rp)=@_; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if (grep { ! /^(?:add|del)$/ } $todo->types('zone')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||
| 126 | 0 | Net::DRI::Exception->die(0,'protocol/EPP',11,'Only zone add/del available for domain'); | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $zadd=$todo->add('zone'); | |||||||||||||||||||||||||||
| 130 | 0 | my $zdel=$todo->del('zone'); | |||||||||||||||||||||||||||
| 131 | 0 | ▶ | return unless $zadd || $zdel; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$zadd or $zdel
MC/DC0%0/2
$zadd or $zdel
$zadd
$zdel
Truth table0%0/3
A or B
A= $zaddB= $zdel
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my @n; | |||||||||||||||||||||||||||
| 134 | 0 | ▶ | push @n,['zoneMgt:add',_generate_rrecs($zadd)] if $zadd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | push @n,['zoneMgt:rem',_generate_rrecs($zdel)] if $zdel; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | $epp->message()->command_extension('zoneMgt', ['update', @n]); | |||||||||||||||||||||||||||
| 138 | 0 | return; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | #################################################################################################### | ||||||||||||||||||||||||||||
| 142 | 1 | 1; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||