| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Zonemaster::Engine::NSArray; |
|
2
|
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
172
|
use version; our $VERSION = version->declare("v1.0.3"); |
|
|
26
|
|
|
|
|
55
|
|
|
|
26
|
|
|
|
|
171
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
26
|
|
|
26
|
|
2611
|
use 5.014002; |
|
|
26
|
|
|
|
|
91
|
|
|
6
|
26
|
|
|
26
|
|
142
|
use warnings; |
|
|
26
|
|
|
|
|
54
|
|
|
|
26
|
|
|
|
|
750
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
26
|
|
|
26
|
|
149
|
use Carp; |
|
|
26
|
|
|
|
|
54
|
|
|
|
26
|
|
|
|
|
1408
|
|
|
9
|
26
|
|
|
26
|
|
162
|
use Zonemaster::Engine::Recursor; |
|
|
26
|
|
|
|
|
55
|
|
|
|
26
|
|
|
|
|
556
|
|
|
10
|
26
|
|
|
26
|
|
135
|
use Zonemaster::Engine::Nameserver; |
|
|
26
|
|
|
|
|
58
|
|
|
|
26
|
|
|
|
|
540
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
26
|
|
|
26
|
|
121
|
use Moose; |
|
|
26
|
|
|
|
|
57
|
|
|
|
26
|
|
|
|
|
170
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'names' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); |
|
15
|
|
|
|
|
|
|
has 'ary' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] } ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub TIEARRAY { |
|
18
|
762
|
|
|
762
|
|
3127
|
my ( $class, @names ) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
762
|
|
|
|
|
4726
|
return $class->new( { names => [ sort { $a cmp $b } @names ] } ); |
|
|
4635
|
|
|
|
|
10518
|
|
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub STORE { |
|
24
|
0
|
|
|
0
|
|
0
|
my ( $self, $index, $value ) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
croak "STORE forbidden for this type of array."; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub STORESIZE { |
|
30
|
0
|
|
|
0
|
|
0
|
my ( $self, $index, $value ) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
croak "STORESIZE forbidden for this type of array."; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub FETCH { |
|
36
|
3317
|
|
|
3317
|
|
7770
|
my ( $self, $index ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
3317
|
100
|
|
|
|
80795
|
if ( exists $self->ary->[$index] ) { |
|
|
|
100
|
|
|
|
|
|
|
39
|
2628
|
|
|
|
|
62222
|
return $self->ary->[$index]; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
689
|
|
|
|
|
18582
|
elsif ( scalar( @{ $self->names } ) == 0 ) { |
|
42
|
14
|
|
|
|
|
79
|
return; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
else { |
|
45
|
675
|
|
|
|
|
1409
|
$self->_load_name( shift @{ $self->names } ); |
|
|
675
|
|
|
|
|
16677
|
|
|
46
|
675
|
|
|
|
|
3890
|
return $self->FETCH( $index ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub FETCHSIZE { |
|
51
|
572
|
|
|
572
|
|
7707
|
my ( $self ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
572
|
|
|
|
|
1129
|
while ( my $name = shift @{ $self->names } ) { |
|
|
909
|
|
|
|
|
24368
|
|
|
54
|
337
|
|
|
|
|
1252
|
$self->_load_name( $name ); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
572
|
|
|
|
|
1078
|
return scalar( @{ $self->ary } ); |
|
|
572
|
|
|
|
|
14015
|
|
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub EXISTS { |
|
61
|
0
|
|
|
0
|
|
0
|
my ( $self, $index ) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
0
|
if ( $self->FETCH( $index ) ) { |
|
64
|
0
|
|
|
|
|
0
|
return 1; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
else { |
|
67
|
0
|
|
|
|
|
0
|
return; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub DELETE { |
|
72
|
0
|
|
|
0
|
|
0
|
my ( $self, $index ) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
croak "DELETE forbidden for this type of array."; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub CLEAR { |
|
78
|
0
|
|
|
0
|
|
0
|
my ( $self ) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
croak "CLEAR forbidden for this type of array."; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub PUSH { |
|
84
|
0
|
|
|
0
|
|
0
|
my ( $self, @values ) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
croak "PUSH forbidden for this type of array."; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub UNSHIFT { |
|
90
|
0
|
|
|
0
|
|
0
|
my ( $self, @values ) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
croak "UNSHIFT forbidden for this type of array."; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub POP { |
|
96
|
0
|
|
|
0
|
|
0
|
my ( $self ) = @_; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
croak "POP forbidden for this type of array."; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub SHIFT { |
|
102
|
0
|
|
|
0
|
|
0
|
my ( $self ) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
croak "SHIFT forbidden for this type of array."; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub SPLICE { |
|
108
|
0
|
|
|
0
|
|
0
|
my ( $self, $offset, $length, @values ) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
0
|
croak "SPLICE forbidden for this type of array."; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub UNTIE { |
|
114
|
0
|
|
|
0
|
|
0
|
my ( $self ) = @_; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
return; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _load_name { |
|
120
|
1012
|
|
|
1012
|
|
2940
|
my ( $self, $name ) = @_; |
|
121
|
1012
|
|
|
|
|
6768
|
my @addrs = Zonemaster::Engine::Recursor->get_addresses_for( $name ); |
|
122
|
1012
|
|
|
|
|
5421
|
foreach my $addr ( sort { $a->ip cmp $b->ip } @addrs ) { |
|
|
631
|
|
|
|
|
2708
|
|
|
123
|
1638
|
|
|
|
|
15596
|
my $ns = Zonemaster::Engine::Nameserver->new( { name => $name, address => $addr } ); |
|
124
|
1638
|
100
|
|
|
|
5248
|
if ( not grep { "$ns" eq "$_" } @{ $self->ary } ) { |
|
|
2698
|
|
|
|
|
104504
|
|
|
|
1638
|
|
|
|
|
45034
|
|
|
125
|
1631
|
|
|
|
|
47747
|
push @{ $self->ary }, $ns; |
|
|
1631
|
|
|
|
|
42535
|
|
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
1012
|
|
|
|
|
8573
|
return; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
26
|
|
|
26
|
|
180764
|
no Moose; |
|
|
26
|
|
|
|
|
72
|
|
|
|
26
|
|
|
|
|
147
|
|
|
133
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 NAME |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Zonemaster::Engine::NSArray - Class implementing arrays that lazily looks up name server addresses from their names |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
tie @ary, 'Zonemaster::Engine::NSArray', @ns_names |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This class is used for the C<glue> and C<ns> attributes of the |
|
148
|
|
|
|
|
|
|
L<Zonemaster::Engine::Zone> class. It is initially seeded with a list of |
|
149
|
|
|
|
|
|
|
names, which will be expanded into proper L<Zonemaster::Engine::Nameserver> |
|
150
|
|
|
|
|
|
|
objects on demand. Be careful with using Perl functions that act on |
|
151
|
|
|
|
|
|
|
whole arrays (particularly C<foreach>), since they will usually force |
|
152
|
|
|
|
|
|
|
the entire array to expand, negating the use of the lazy-loading. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 METHODS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
These are all methods implementing the Perl tie interface. They have no independent use. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item TIEARRAY |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item STORE |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item STORESIZE |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item FETCH |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item FETCHSIZE |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item EXISTS |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item DELETE |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item CLEAR |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item PUSH |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item UNSHIFT |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item POP |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item SHIFT |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item SPLICE |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item UNTIE |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 AUTHOR |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Calle Dybedahl, C<< <calle at init.se> >> |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |