line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SRS::EPP::Common::Domain::NameServers; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$SRS::EPP::Common::Domain::NameServers::VERSION = '0.22'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2623
|
use Moose::Role; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'make_response'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Given a list of EPP nameservers, translate it into a list of SRS nameservers |
11
|
|
|
|
|
|
|
# If a HostObj is found in the EPP list (which is not supported) then an |
12
|
|
|
|
|
|
|
# exception is returned with an appropriate error response that can be returned |
13
|
|
|
|
|
|
|
# to the client (created via the required method 'make_response'. |
14
|
|
|
|
|
|
|
# This might be a slightly unusual interface, but it means the generation of the |
15
|
|
|
|
|
|
|
# response is consistent across consumers of this role |
16
|
|
|
|
|
|
|
# TODO: in hindsight, perhaps we should split this into validate/translate methods, |
17
|
|
|
|
|
|
|
# similar to SRS::EPP::Common::Contact |
18
|
|
|
|
|
|
|
sub translate_ns_epp_to_srs { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
my @ns = @_; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my @ns_objs; |
23
|
0
|
|
|
|
|
|
foreach my $ns (@ns) { |
24
|
0
|
0
|
|
|
|
|
unless ($ns->isa('XML::EPP::Domain::HostAttr')) { |
25
|
0
|
|
|
|
|
|
die $self->make_response( |
26
|
|
|
|
|
|
|
Error => ( |
27
|
|
|
|
|
|
|
code => 2102, |
28
|
|
|
|
|
|
|
exception => XML::EPP::Error->new( |
29
|
|
|
|
|
|
|
value => $ns, |
30
|
|
|
|
|
|
|
reason => 'hostObj not supported', |
31
|
|
|
|
|
|
|
) |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $ips = $ns->addrs; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# We reject any requests that have more than 1 ip address, as the SRS |
39
|
|
|
|
|
|
|
# doesn't really support that (altho an ipv4 and ipv6 address are allowed) |
40
|
0
|
|
|
|
|
|
my %translated_ips; |
41
|
0
|
|
|
|
|
|
foreach my $ip (@$ips) { |
42
|
0
|
|
|
|
|
|
my $type = $ip->ip; |
43
|
0
|
0
|
|
|
|
|
if ($translated_ips{$type}) { |
44
|
0
|
|
|
|
|
|
die $self->make_response( |
45
|
|
|
|
|
|
|
Error => ( |
46
|
|
|
|
|
|
|
code => 2102, |
47
|
|
|
|
|
|
|
exception => XML::EPP::Error->new( |
48
|
|
|
|
|
|
|
value => $ns->name, |
49
|
|
|
|
|
|
|
reason => |
50
|
|
|
|
|
|
|
'multiple addresses for a nameserver of the same ip version not supported', |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
) |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$translated_ips{$type} = $ip->value; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
push @ns_objs, XML::SRS::Server->new( |
|
|
0
|
|
|
|
|
|
60
|
|
|
|
|
|
|
fqdn => $ns->name, |
61
|
|
|
|
|
|
|
($translated_ips{v4} ? (ipv4_addr => $translated_ips{v4}) : ()), |
62
|
|
|
|
|
|
|
($translated_ips{v6} ? (ipv6_addr => $translated_ips{v6}) : ()), |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return @ns_objs; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub translate_ns_srs_to_epp { |
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
71
|
0
|
|
|
|
|
|
my @ns = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my @nameservers; |
74
|
0
|
|
|
|
|
|
foreach my $srs_ns (@ns) { |
75
|
0
|
|
|
|
|
|
my ($ipv4addr, $ipv6addr); |
76
|
0
|
0
|
|
|
|
|
$ipv4addr = XML::EPP::Host::Address->new( |
77
|
|
|
|
|
|
|
value => $srs_ns->ipv4_addr, |
78
|
|
|
|
|
|
|
ip => 'v4', |
79
|
|
|
|
|
|
|
) if $srs_ns->ipv4_addr; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
$ipv6addr = XML::EPP::Host::Address->new( |
82
|
|
|
|
|
|
|
value => $srs_ns->ipv6_addr, |
83
|
|
|
|
|
|
|
ip => 'v6', |
84
|
|
|
|
|
|
|
) if $srs_ns->ipv6_addr; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
0
|
|
|
|
push @nameservers, XML::EPP::Domain::HostAttr->new( |
|
|
|
0
|
|
|
|
|
87
|
|
|
|
|
|
|
name => $srs_ns->fqdn, |
88
|
|
|
|
|
|
|
addrs => [ |
89
|
|
|
|
|
|
|
$ipv4addr // (), |
90
|
|
|
|
|
|
|
$ipv6addr // (), |
91
|
|
|
|
|
|
|
], |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
return scalar @ns != 1 ? @nameservers : $nameservers[0]; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |