line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## Domain Registry Interface, EPP E.164 Number Mapping (RFC4114) |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## Copyright (c) 2005-2009,2013 Patrick Mevzek . 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::E164; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
940
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
18
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use Net::DRI::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
21
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Exception; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
828
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $NS='urn:ietf:params:xml:ns:e164epp-1.0'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=pod |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Net::DRI::Protocol::EPP::Extensions::E164 - EPP E.164 Number Mapping (RFC4114) for Net::DRI |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Please see the README file for details. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SUPPORT |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
For now, support questions should be sent to: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Enetdri@dotandco.comE |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Please also see the SUPPORT file in the distribution. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SEE ALSO |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Ehttp://www.dotandco.com/services/software/Net-DRI/E |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 AUTHOR |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Patrick Mevzek, Enetdri@dotandco.comE |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 COPYRIGHT |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Copyright (c) 2005-2009,2013 Patrick Mevzek . |
54
|
|
|
|
|
|
|
All rights reserved. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
57
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
58
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
59
|
|
|
|
|
|
|
(at your option) any later version. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
See the LICENSE file that comes with this distribution for more details. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#################################################################################################### |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub register_commands |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
0
|
0
|
|
my ($class,$version)=@_; |
70
|
0
|
|
|
|
|
|
my %tmp=( |
71
|
|
|
|
|
|
|
info => [ undef, \&info_parse ], |
72
|
|
|
|
|
|
|
create => [ \&create, undef ], |
73
|
|
|
|
|
|
|
update => [ \&update, undef ], |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return { 'domain' => \%tmp }; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
0
|
|
sub capabilities_add { return ('domain_update','e164',['add','del']); } |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#################################################################################################### |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub format_naptr |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
0
|
0
|
|
my $e=shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
0
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('Attributes order, pref and svc must exist') unless ((ref($e) eq 'HASH') && exists($e->{order}) && exists($e->{pref}) && exists($e->{svc})); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Order must be 16-bit unsigned integer') unless Net::DRI::Util::verify_ushort($e->{order}); |
90
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Pref must be 16-bit unsigned integer') unless Net::DRI::Util::verify_ushort($e->{pref}); |
91
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Svc must be at least 1 character as xml token type') unless Net::DRI::Util::xml_is_token($e->{svc},1,undef); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my @c; |
94
|
0
|
|
|
|
|
|
push @c,['e164:order',$e->{order}]; |
95
|
0
|
|
|
|
|
|
push @c,['e164:pref',$e->{pref}]; |
96
|
0
|
0
|
|
|
|
|
if (exists($e->{flags})) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Flags must be a single letter or number') unless ($e->{flags}=~m/^[A-Z0-9]$/i); |
99
|
0
|
|
|
|
|
|
push @c,['e164:flags',$e->{flags}]; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
push @c,['e164:svc',$e->{svc}]; |
102
|
0
|
0
|
|
|
|
|
if (exists($e->{regex})) |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Regex must be at least 1 character as xml token type') unless Net::DRI::Util::xml_is_token($e->{regex},1,undef); |
105
|
0
|
|
|
|
|
|
push @c,['e164:regex',$e->{regex}]; |
106
|
|
|
|
|
|
|
} |
107
|
0
|
0
|
|
|
|
|
if (exists($e->{replacement})) |
108
|
|
|
|
|
|
|
{ |
109
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Regex must be between 1 and 255 characters as xml token type') unless Net::DRI::Util::xml_is_token($e->{regex},1,255); |
110
|
0
|
|
|
|
|
|
push @c,['e164:replacement',$e->{replacement}]; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return @c; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#################################################################################################### |
117
|
|
|
|
|
|
|
########### Query commands |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub info_parse |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
|
|
0
|
0
|
|
my ($po,$otype,$oaction,$oname,$rinfo)=@_; |
122
|
0
|
|
|
|
|
|
my $mes=$po->message(); |
123
|
0
|
0
|
|
|
|
|
return unless $mes->is_success(); |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $infdata=$mes->get_extension($NS,'infData'); |
126
|
0
|
0
|
|
|
|
|
return unless defined $infdata; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my @naptr; |
129
|
0
|
|
|
|
|
|
foreach my $el ($infdata->getChildrenByTagNameNS($NS,'naptr')) |
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
|
|
|
my %n; |
132
|
0
|
|
|
|
|
|
foreach my $sel (Net::DRI::Util::xml_list_children($el)) |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
my ($name,$c)=@$sel; |
135
|
0
|
0
|
|
|
|
|
if ($name=~m/^(order|pref|flags|svc|regex|replacement)$/) |
136
|
|
|
|
|
|
|
{ |
137
|
0
|
|
|
|
|
|
$n{$1}=$c->textContent(); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
0
|
|
|
|
|
|
push @naptr,\%n; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$rinfo->{domain}->{$oname}->{e164}=\@naptr; |
144
|
0
|
|
|
|
|
|
return; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
############ Transform commands |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub create |
150
|
|
|
|
|
|
|
{ |
151
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
152
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $def=$epp->default_parameters(); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
## IENUMAT works without the e164 extension part |
157
|
0
|
0
|
0
|
|
|
|
unless (exists($rd->{e164}) && (ref($rd->{e164}) eq 'ARRAY') && @{$rd->{e164}}) |
|
0
|
|
0
|
|
|
|
|
158
|
|
|
|
|
|
|
{ |
159
|
0
|
0
|
0
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('One or more E164 data block must be provided') unless (defined($def) && exists($def->{rfc4114_relax}) && $def->{rfc4114_relax}); |
|
|
|
0
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('e164:create','xmlns:e164="urn:ietf:params:xml:ns:e164epp-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:e164epp-1.0 e164epp-1.0.xsd"'); |
164
|
0
|
|
|
|
|
|
my @n=map { ['e164:naptr',format_naptr($_)] } (@{$rd->{e164}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@n); |
166
|
0
|
|
|
|
|
|
return; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub update |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$todo)=@_; |
172
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my $toadd=$todo->add('e164'); |
175
|
0
|
|
|
|
|
|
my $todel=$todo->del('e164'); |
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
0
|
|
|
|
return unless (defined($toadd) || defined($todel)); |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('e164:update','xmlns:e164="urn:ietf:params:xml:ns:e164epp-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:e164epp-1.0 e164epp-1.0.xsd"'); |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my @n; |
182
|
0
|
0
|
|
|
|
|
push @n,['e164:add',map { ['e164:naptr',format_naptr($_)] } (ref($toadd) eq 'ARRAY')? @$toadd : ($toadd)] if (defined($toadd)); |
|
0
|
0
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
push @n,['e164:rem',map { ['e164:naptr',format_naptr($_)] } (ref($todel) eq 'ARRAY')? @$todel : ($todel)] if (defined($todel)); |
|
0
|
0
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@n); |
186
|
0
|
|
|
|
|
|
return; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
#################################################################################################### |
190
|
|
|
|
|
|
|
1; |