line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim:ts=4:sw=4:expandtab |
2
|
|
|
|
|
|
|
package App::AllKnowingDNS::Config; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
7558
|
use Mouse; |
|
5
|
|
|
|
|
178968
|
|
|
5
|
|
|
|
|
67
|
|
5
|
5
|
|
|
5
|
|
4446
|
use App::AllKnowingDNS::Zone; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
146
|
|
6
|
5
|
|
|
5
|
|
1876
|
use App::AllKnowingDNS::Util; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
320
|
|
7
|
5
|
|
|
5
|
|
34
|
use Data::Dumper; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
2112
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
App::AllKnowingDNS::Config - configuration object |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Note: User documentation is in L(1). |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module defines an object which holds the parsed version of the |
18
|
|
|
|
|
|
|
AllKnowingDNS configuration file. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 FUNCTIONS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'listen_addresses' => ( |
25
|
|
|
|
|
|
|
traits => [ 'Array' ], |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
28
|
|
|
|
|
|
|
default => sub { [] }, |
29
|
|
|
|
|
|
|
handles => { |
30
|
|
|
|
|
|
|
add_listen_address => 'push', |
31
|
|
|
|
|
|
|
all_listen_addresses => 'elements', |
32
|
|
|
|
|
|
|
count_listen_addresses => 'count', |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'zones' => ( |
37
|
|
|
|
|
|
|
traits => [ 'Array' ], |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
isa => 'ArrayRef[App::AllKnowingDNS::Zone]', |
40
|
|
|
|
|
|
|
default => sub { [] }, |
41
|
|
|
|
|
|
|
handles => { |
42
|
|
|
|
|
|
|
all_zones => 'elements', |
43
|
|
|
|
|
|
|
has_zones => 'count', |
44
|
|
|
|
|
|
|
count_zones => 'count', |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub add_zone { |
49
|
9
|
|
|
9
|
0
|
1477
|
my ($self, $zone) = @_; |
50
|
|
|
|
|
|
|
|
51
|
9
|
|
|
|
|
40
|
my $aaaazone = quotemeta($zone->resolves_to); |
52
|
9
|
|
|
|
|
45
|
$aaaazone =~ s/\\%DIGITS\\%/([a-z0-9]+)/i; |
53
|
9
|
|
|
|
|
234
|
$zone->aaaazone(qr/^$aaaazone$/); |
54
|
|
|
|
|
|
|
|
55
|
9
|
|
|
|
|
83
|
$zone->ptrzone(App::AllKnowingDNS::Util::netmask_to_ptrzone($zone->network)); |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
26
|
push @{$self->zones}, $zone; |
|
9
|
|
|
|
|
44
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 zone_for_ptr($zone) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns the appropriate zone for the given PTR query or undef if there is no |
63
|
|
|
|
|
|
|
appropriate zone. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Example: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $query = '7.c.e.2.3.4.e.f.f.f.b.d.9.1.2.0.' . |
68
|
|
|
|
|
|
|
'0.c.c.c.e.0.0.1.8.8.d.4.1.0.0.2.ip6.arpa'; |
69
|
|
|
|
|
|
|
my $zone = $config->zone_for_ptr($query); |
70
|
|
|
|
|
|
|
return 'NXDOMAIN' unless defined($zone); |
71
|
|
|
|
|
|
|
... |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub zone_for_ptr { |
76
|
7
|
|
|
7
|
1
|
446
|
my ($self, $query) = @_; |
77
|
|
|
|
|
|
|
|
78
|
7
|
|
|
|
|
33
|
for my $zone ($self->all_zones) { |
79
|
6
|
|
|
|
|
39
|
my $suffix = $zone->ptrzone; |
80
|
6
|
100
|
|
|
|
39
|
return $zone if substr($query, -1 * length($suffix)) eq $suffix; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
241
|
return undef; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 zone_for_aaaa($zone) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the appropriate zone for the given AAAA query or undef if there is no |
89
|
|
|
|
|
|
|
appropriate zone. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Example: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $query = 'ipv6-foo.nutzer.raumzeitlabor.de'; |
94
|
|
|
|
|
|
|
my $zone = $config->zone_for_aaaa($query); |
95
|
|
|
|
|
|
|
return 'NXDOMAIN' unless defined($zone); |
96
|
|
|
|
|
|
|
... |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub zone_for_aaaa { |
101
|
9
|
|
|
9
|
1
|
16
|
my ($self, $query) = @_; |
102
|
|
|
|
|
|
|
|
103
|
9
|
|
|
|
|
39
|
for my $zone ($self->all_zones) { |
104
|
8
|
100
|
|
|
|
119
|
return $zone if $query =~ $zone->aaaazone; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
4
|
|
|
|
|
40
|
return undef; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |