line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2009-2014 David Caldwell, All Rights Reserved. |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::DNS::Create::Tiny; |
4
|
1
|
|
|
1
|
|
6
|
use feature ':5.10'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
139
|
|
5
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Net::DNS::Create qw(internal full_host email interval); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
530
|
use File::Slurp qw(write_file); |
|
1
|
|
|
|
|
10902
|
|
|
1
|
|
|
|
|
707
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %config; |
12
|
|
|
|
|
|
|
sub import { |
13
|
1
|
|
|
1
|
|
1
|
my $package = shift; |
14
|
1
|
|
|
|
|
4
|
my %c = @_; |
15
|
1
|
|
|
|
|
6
|
$config{$_} = $c{$_} for keys %c; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub tiny_escape($) { |
19
|
11
|
|
|
11
|
0
|
157
|
my ($f) = @_; |
20
|
11
|
|
|
|
|
118
|
$f =~ s/(:|\\|[^ -~])/sprintf "\\%03o", ord($1)/eg; |
|
45
|
|
|
|
|
144
|
|
21
|
11
|
|
|
|
|
32
|
$f |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub domainname_encode($;$) { |
25
|
7
|
|
|
7
|
0
|
101
|
my ($node, $domain) = @_; |
26
|
7
|
|
|
|
|
15
|
$node = full_host($node, $domain); |
27
|
7
|
|
|
|
|
22
|
join('', map { chr(length $_).$_ } split /\./, $node, -1); |
|
31
|
|
|
|
|
62
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub C(@) { # "Colon" |
31
|
33
|
|
|
33
|
0
|
494
|
join(':', @_) |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my @domain; |
35
|
|
|
|
|
|
|
sub domain($$) { |
36
|
1
|
|
|
1
|
0
|
2
|
my ($package, $domain, $entries) = @_; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
2
|
my @conf = map { ; |
39
|
33
|
|
|
|
|
95
|
my $rr = lc $_->type; |
40
|
33
|
|
|
|
|
369
|
my $fqdn = $_->name . '.'; |
41
|
|
|
|
|
|
|
|
42
|
33
|
50
|
50
|
|
|
732
|
$rr eq 'a' ? '='.C($fqdn,$_->address,$_->ttl) : |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$rr eq 'cname' ? 'C'.C($fqdn,$_->cname.'.',$_->ttl) : |
44
|
|
|
|
|
|
|
$rr eq 'rp' ? ':'.C($fqdn,17,tiny_escape(domainname_encode(email($_->mbox)).domainname_encode($_->txtdname)),$_->ttl) : |
45
|
|
|
|
|
|
|
$rr eq 'mx' ? '@'.C($fqdn,'',$_->exchange.'.',$_->preference,'',$_->ttl) : |
46
|
|
|
|
|
|
|
$rr eq 'ns' ? '&'.C($fqdn,'',$_->nsdname.'.',$_->ttl) : |
47
|
|
|
|
|
|
|
$rr eq 'txt' ? "'".C($fqdn,tiny_escape(join('',$_->char_str_list)),$_->ttl) : |
48
|
|
|
|
|
|
|
$rr eq 'soa' ? 'Z'.C($fqdn, |
49
|
|
|
|
|
|
|
$_->mname.'.', |
50
|
|
|
|
|
|
|
email($_->rname), |
51
|
|
|
|
|
|
|
$_->serial || '', |
52
|
|
|
|
|
|
|
$_->refresh, $_->retry, $_->expire, $_->minimum, $_->ttl) : |
53
|
|
|
|
|
|
|
$rr eq 'srv' ? ':'.C($fqdn,33,tiny_escape(pack("nnn", $_->priority, $_->weight, $_->port) |
54
|
|
|
|
|
|
|
.domainname_encode($_->target)),$_->ttl) : |
55
|
|
|
|
|
|
|
die "Don't know how to handle \"$rr\" RRs yet."; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} @$entries; |
58
|
|
|
|
|
|
|
|
59
|
33
|
|
|
|
|
105
|
push @domain, "# $domain\n" . |
60
|
|
|
|
|
|
|
"#\n" . |
61
|
1
|
|
|
|
|
6
|
join('', map { "$_\n" } @conf) . |
62
|
|
|
|
|
|
|
"\n"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub master { |
66
|
1
|
|
|
1
|
0
|
3
|
my ($package, $filename) = @_; |
67
|
1
|
|
|
|
|
5
|
write_file($filename, @domain); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
0
|
|
sub domain_list($@) { |
71
|
|
|
|
|
|
|
# There are no separate zone files in a tiny setup. |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub master_list($$) { |
75
|
0
|
|
|
0
|
0
|
|
print "$_[0]\n" |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |