| 1 | package DNS::Oterica::RecordMaker::TinyDNS; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: a tinydns recordmaker for DNSO. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | $DNS::Oterica::RecordMaker::TinyDNS::VERSION = '0.313'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 7 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 8 | #pod This role provides logic for generating lines for the F<tinydns-data> program | ||||||||||||||||||||||||||||||||||||||||||
| 9 | #pod to consume. | ||||||||||||||||||||||||||||||||||||||||||
| 10 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 11 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | has suppress_duplicate_a => ( | |||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | has _a_cache => ( | ||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub _default_ttl { 1800 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_ttl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _serial_number { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | return($ENV{DNS_OTERICA_SN} || '') | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serial_number: not called CC=2 SCAR=17.9
Condition0%0/2
$ENV{'DNS_OTERICA_SN'} || ''
MC/DC0%0/1
$ENV{'DNS_OTERICA_SN'} || ''
$ENV{'DNS_OTERICA_SN'}
Truth table0%0/2
A
A= $ENV{'DNS_OTERICA_SN'}
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub _timestamp { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return($ENV{DNS_OTERICA_TS} || '') | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timestamp: not called CC=2 SCAR=17.9
Condition0%0/2
$ENV{'DNS_OTERICA_TS'} || ''
MC/DC0%0/1
$ENV{'DNS_OTERICA_TS'} || ''
$ENV{'DNS_OTERICA_TS'}
Truth table0%0/2
A
A= $ENV{'DNS_OTERICA_TS'}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | #pod =method comment | ||||||||||||||||||||||||||||||||||||||||||
| 35 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 36 | #pod my $line = $rec->comment("Hello, world!"); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 38 | #pod This returns a line that is a one-line commment. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 40 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | sub comment { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my ($self, $comment) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return "# $comment\n"; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | #pod =method location | ||||||||||||||||||||||||||||||||||||||||||
| 49 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 50 | #pod This returns a location line. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 52 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub location { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ($self, $location) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return if $location->code eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | Carp::confess("location codes must be two-character") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | unless length $location->code == 2; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @prefixes = $location->_class_prefixes; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | map { sprintf "%%%s:%s\n", $location->code, $_ } @prefixes; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | sub __ip_locode_pairs { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ip_locode_pairs: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | Carp::confess('no node provided') unless $rec->{node}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | return | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | map {; [ $_->[0] => $_->[1]->code ] } | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $rec->{node}->interfaces; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | sub _generic { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($self, $op, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $cache = $self->_a_cache; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | INTERFACE: for my $if ($self->__ip_locode_pairs($rec)) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($op eq '+') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $key = join q{/}, $rec->{name}, @$if; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($cache->{$key}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | push @lines, $self->comment("skipped duplicate + for $key"); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | next INTERFACE; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | push @lines, sprintf "%s%s:%s:%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 92 | $op, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | $rec->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | $if->[0], | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 97 | $if->[1], | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | #pod =method a_and_ptr | ||||||||||||||||||||||||||||||||||||||||||
| 105 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 106 | #pod Generate an C<=> line, the bread and butter A and PTR record pair for a | ||||||||||||||||||||||||||||||||||||||||||
| 107 | #pod hostname and IP. | ||||||||||||||||||||||||||||||||||||||||||
| 108 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 109 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # =fqdn:ip:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 112 | sub a_and_ptr { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
a_and_ptr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->a($rec), | |||||||||||||||||||||||||||||||||||||||||
| 117 | $self->ptr($rec), | ||||||||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | #pod =method ptr | ||||||||||||||||||||||||||||||||||||||||||
| 122 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 123 | #pod Generate an C<^> line, for the reverse DNS of an IP address. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 125 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | # ^fqdn:ip:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # can't use __generic here because it wants to look at interfaces, and we want | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # the reverse of that | ||||||||||||||||||||||||||||||||||||||||||
| 130 | sub ptr { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ptr: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | for my $if ($self->__ip_locode_pairs($rec)) { | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $ip = $if->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my @bytes = reverse split /\./, $ip; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | splice @bytes, 1, 1, '0-24', $bytes[1] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$bytes[1] eq 237 and $bytes[2] eq 72 and $bytes[3] eq 208
$bytes[1] eq 237 and $bytes[2] eq 72
MC/DC0%0/3
$bytes[1] eq 237 and $bytes[2] eq 72 and $bytes[3] eq 208
$bytes[1] eq 237
$bytes[2] eq 72
$bytes[3] eq 208
Truth table0%0/4
A and B and C
A= $bytes[1] eq 237B= $bytes[2] eq 72C= $bytes[3] eq 208
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | if $bytes[1] eq 237 && $bytes[2] eq 72 && $bytes[3] eq 208; | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $extended_arpa = join '.', @bytes, 'in-addr', 'arpa'; | |||||||||||||||||||||||||||||||||||||||||
| 142 | push @lines, sprintf "^%s:%s:%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 143 | $extended_arpa, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | $rec->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | $if->[1] eq 'FB' ? '' : $if->[1]; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 154 | # | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # TODO find out why we generate Z and & records for our IPs and refactor this | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # to not duplicate effort with &ptr and the like. problem is that &a calls &ptr | ||||||||||||||||||||||||||||||||||||||||||
| 157 | # so having the code there means it gets called for every time we generate a + | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # record, totally not what we want. What we want is for this to be called once | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # for every IP address, not every hostname. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | sub soa_and_ns_for_ip { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_and_ns_for_ip: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $node = $rec->{node}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $ns_f = $node->hub->ns_family; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my %ns = $node->hub->node_family($ns_f)->ns_nodes; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $ns_1 = (keys %ns)[0]; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $addr = $node->hub->soa_rname; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $ip = $rec->{ip}; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my @bytes = reverse split /\./, $ip; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $arpa = join '.', @bytes, 'in-addr', 'arpa'; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | push @lines, sprintf "Z%s:%s:%s::::::%s:%s:%s\n", | |||||||||||||||||||||||||||||||||||||||||
| 174 | $arpa, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | $ns_1, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | $addr, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 180 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | for my $ns (keys %ns) { | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | push @lines, $self->domain({ | |||||||||||||||||||||||||||||||||||||||||
| 184 | domain => $arpa, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | ip => $ip, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | ns => $ns, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | # +fqdn:ip:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 193 | sub a { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
a: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my @lines = $self->_generic(q{+}, $rec); | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # @fqdn:ip:x:dist:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 201 | sub mx { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mx: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | my $mx_name = defined $rec->{mx} ? $rec->{mx} | ||||||||||||||||||||||||||||||||||||||||||
| 207 | : $rec->{node} ? $rec->{node}->fqdn | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | : Carp::confess('neither mx nor node given as mx for mx record'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | for my $if ($self->__ip_locode_pairs($rec)) { | |||||||||||||||||||||||||||||||||||||||||
| 211 | push @lines, sprintf "@%s:%s:%s:%s:%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 212 | $rec->{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ($rec->{no_ip} ? '' : $if->[0]), | ||||||||||||||||||||||||||||||||||||||||||
| 214 | $mx_name, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | $rec->{dist} || 10, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$rec->{'dist'} || 10
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/1
$rec->{'dist'} || 10
$rec->{'dist'}
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/2
A
A= $rec->{'dist'}
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | $if->[1], | ||||||||||||||||||||||||||||||||||||||||||
| 219 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | # .fqdn:ip:x:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # This doesn't handle nodes, because I don't want to deal with ip-less records, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # which would cause __generic to barf. This is just a hack for now. | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # -- rjbs, 2008-12-15 | ||||||||||||||||||||||||||||||||||||||||||
| 229 | sub domain { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domain: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | push @lines, sprintf "&%s:%s:%s:%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 235 | $rec->{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | $rec->{ip} || '', | ||||||||||||||||||||||||||||||||||||||||||
| 237 | $rec->{ns}, | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$rec->{'ip'} || ''
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/1
$rec->{'ip'} || ''
$rec->{'ip'}
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/2
A
A= $rec->{'ip'}
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 241 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | sub soa_and_ns { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soa_and_ns: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | push @lines, sprintf "Z%s:%s:%s:%s:::::%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 252 | $rec->{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | $rec->{ns} || '', | ||||||||||||||||||||||||||||||||||||||||||
| 254 | $rec->{node}->hub->soa_rname, | ||||||||||||||||||||||||||||||||||||||||||
| 255 | $self->_serial_number, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$rec->{'ns'} || ''
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/1
$rec->{'ns'} || ''
$rec->{'ns'}
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/2
A
A= $rec->{'ns'}
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | # Cfqdn:p:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 266 | sub cname { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cname: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | push @lines, sprintf "C%s:%s:%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 272 | $rec->{cname}, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | $rec->{domain} || '', | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$rec->{'domain'} || ''
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/1
$rec->{'domain'} || ''
$rec->{'domain'}
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/2
A
A= $rec->{'domain'}
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 276 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 277 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | sub txt { | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
txt: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $name = $rec->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $name = $rec->{node}->fqdn if ! $name && $rec->{node}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $name and $rec->{"node"}
MC/DC0%0/2
not $name and $rec->{"node"}
not $name
$rec->{"node"}
Truth table0%0/3
not(A) and B
A= not $nameB= $rec->{"node"}
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | Carp::confess("no record name or node given for txt record") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table0%0/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | unless defined $name and length $name; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # 'fqdn:s:ttl:timestamp:lo | ||||||||||||||||||||||||||||||||||||||||||
| 293 | push @lines, sprintf qq{'%s:%s:%s:%s:%s\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $name, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | _colon_safe($rec->{text}), | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | $self->_timestamp, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | sub _colon_safe { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $str = $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_colon_safe: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $str =~ s/([^A-Za-z0-9=])/sprintf '\\%03o', ord $1/ge; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $str; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | sub _escaped_octals { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | join q{}, map {; sprintf '\\%03o', ord } split //, pack 'n', $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_escaped_octals: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | sub _hostname_to_labels { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | my @labels = split /\./, $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hostname_to_labels: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $str .= sprintf('\\%03o', length) . $_ for @labels; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $str .= '\000'; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | #pod =method srv | ||||||||||||||||||||||||||||||||||||||||||
| 324 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 325 | #pod @lines = $rec->srv({ | ||||||||||||||||||||||||||||||||||||||||||
| 326 | #pod # We want to produce _finger._tcp.example.com for port 70 | ||||||||||||||||||||||||||||||||||||||||||
| 327 | #pod domain => 'example.com', | ||||||||||||||||||||||||||||||||||||||||||
| 328 | #pod service => 'finger', | ||||||||||||||||||||||||||||||||||||||||||
| 329 | #pod protocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 330 | #pod target => 'f.example.com', | ||||||||||||||||||||||||||||||||||||||||||
| 331 | #pod port => 70, | ||||||||||||||||||||||||||||||||||||||||||
| 332 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 333 | #pod priority => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 334 | #pod weight => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 335 | #pod }); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 337 | #pod This returns lines for SRV records following RFC 2782. It takes the following | ||||||||||||||||||||||||||||||||||||||||||
| 338 | #pod special arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 339 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 340 | #pod domain - the domain offering service | ||||||||||||||||||||||||||||||||||||||||||
| 341 | #pod service - the well-known service name (http, imaps, finger) | ||||||||||||||||||||||||||||||||||||||||||
| 342 | #pod protocol - tcp or udp | ||||||||||||||||||||||||||||||||||||||||||
| 343 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 344 | #pod target - the host providing service | ||||||||||||||||||||||||||||||||||||||||||
| 345 | #pod port - the port the service listens on | ||||||||||||||||||||||||||||||||||||||||||
| 346 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 347 | #pod priority - numeric priority; lower numbers should be used first | ||||||||||||||||||||||||||||||||||||||||||
| 348 | #pod weight - weight to break priority ties; higher numbers preferred | ||||||||||||||||||||||||||||||||||||||||||
| 349 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 350 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | sub srv { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
srv: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | Carp::confess("srv record with no target! use empty string for null target") | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | unless defined $rec->{target}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | for my $needed (qw(port service domain)) { | |||||||||||||||||||||||||||||||||||||||||
| 359 | Carp::confess("tried to make srv record with no $needed!") | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | unless defined $rec->{$needed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | my $priority = $rec->{priority} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rec->{'priority'} || 0
MC/DC0%0/1
$rec->{'priority'} || 0
$rec->{'priority'}
Truth table0%0/2
A
A= $rec->{'priority'}
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $weight = $rec->{weight} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rec->{'weight'} || 0
MC/DC0%0/1
$rec->{'weight'} || 0
$rec->{'weight'}
Truth table0%0/2
A
A= $rec->{'weight'}
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 367 | push @lines, sprintf ":_%s._%s.%s:33:%s%s%s%s:%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 368 | $rec->{service}, | ||||||||||||||||||||||||||||||||||||||||||
| 369 | $rec->{protocol} || 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 370 | $rec->{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | _escaped_octals($priority), | ||||||||||||||||||||||||||||||||||||||||||
| 372 | _escaped_octals($weight), | ||||||||||||||||||||||||||||||||||||||||||
| 373 | _escaped_octals($rec->{port}), | ||||||||||||||||||||||||||||||||||||||||||
| 374 | _hostname_to_labels($rec->{target}), | ||||||||||||||||||||||||||||||||||||||||||
| 375 | $rec->{ttl} || $self->_default_ttl, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | $rec->{location} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/7
$rec->{'protocol'} || 'tcp'
$rec->{'ttl'} || $self->_default_ttl
$rec->{'location'} || ''
MC/DC0%0/1
$rec->{'protocol'} || 'tcp'
$rec->{'protocol'}
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
MC/DC0%0/1
$rec->{'location'} || ''
$rec->{'location'}
Truth table0%0/2
A
A= $rec->{'protocol'}
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
Truth table0%0/2
A
A= $rec->{'location'}
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | #pod =method dkim | ||||||||||||||||||||||||||||||||||||||||||
| 382 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 383 | #pod This returns lines for TXT records for DKIM keys. It takes the following | ||||||||||||||||||||||||||||||||||||||||||
| 384 | #pod arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 385 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 386 | #pod domain - the domain | ||||||||||||||||||||||||||||||||||||||||||
| 387 | #pod selector - the key selector | ||||||||||||||||||||||||||||||||||||||||||
| 388 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 389 | #pod ttl - record time to live | ||||||||||||||||||||||||||||||||||||||||||
| 390 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 391 | #pod tags - the DKIM record tags, a hashref | ||||||||||||||||||||||||||||||||||||||||||
| 392 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 393 | #pod Any tag given in the hashref will be included. C<p> is required. | ||||||||||||||||||||||||||||||||||||||||||
| 394 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 395 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | sub dkim { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | my ($self, $rec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dkim: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | Carp::confess("no domain for DKIM record") unless $rec->{domain}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | Carp::confess("no selector for DKIM record") unless $rec->{selector}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | Carp::confess("no public key for DKIM record") unless $rec->{tags}{p}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $tags = $rec->{tags}; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $name = "$rec->{selector}._domainkey.$rec->{domain}"; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $text = join q{; }, map {; "$_=$tags->{$_}" } | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sort { $a eq 'v' ? -1 : $b eq 'v' ? 1 : ($a cmp $b) } keys %$tags; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # We can't use ->txt because tinydns will split TXT records (generated by ') | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # up into 127b chunks. DKIM doesn't let you do that. -- rjbs, 2016-10-04 | ||||||||||||||||||||||||||||||||||||||||||
| 411 | return sprintf ":%s:16:\\%03o%s:%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 412 | $name, | ||||||||||||||||||||||||||||||||||||||||||
| 413 | length($text), | ||||||||||||||||||||||||||||||||||||||||||
| 414 | _colon_safe($text), | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | $rec->{ttl} || $self->_default_ttl; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rec->{'ttl'} || $self->_default_ttl
MC/DC0%0/2
$rec->{'ttl'} || $self->_default_ttl
$rec->{'ttl'}
$self->_default_ttl
Truth table0%0/3
A || B
A= $rec->{'ttl'}B= $self->_default_ttl
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | DNS::Oterica::RecordMaker::TinyDNS - a tinydns recordmaker for DNSO. | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | version 0.313 | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | This role provides logic for generating lines for the F<tinydns-data> program | ||||||||||||||||||||||||||||||||||||||||||
| 438 | to consume. | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | =head1 PERL VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | This library should run on perls released even a long time ago. It should work | ||||||||||||||||||||||||||||||||||||||||||
| 443 | on any version of perl released in the last five years. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | Although it may work on older versions of perl, no guarantee is made that the | ||||||||||||||||||||||||||||||||||||||||||
| 446 | minimum required version will not be increased. The version may be increased | ||||||||||||||||||||||||||||||||||||||||||
| 447 | for any reason, and there is no promise that patches will be accepted to lower | ||||||||||||||||||||||||||||||||||||||||||
| 448 | the minimum required perl. | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =head2 comment | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | my $line = $rec->comment("Hello, world!"); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | This returns a line that is a one-line commment. | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | =head2 location | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | This returns a location line. | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | =head2 a_and_ptr | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | Generate an C<=> line, the bread and butter A and PTR record pair for a | ||||||||||||||||||||||||||||||||||||||||||
| 465 | hostname and IP. | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | =head2 ptr | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | Generate an C<^> line, for the reverse DNS of an IP address. | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | =head2 srv | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | @lines = $rec->srv({ | ||||||||||||||||||||||||||||||||||||||||||
| 474 | # We want to produce _finger._tcp.example.com for port 70 | ||||||||||||||||||||||||||||||||||||||||||
| 475 | domain => 'example.com', | ||||||||||||||||||||||||||||||||||||||||||
| 476 | service => 'finger', | ||||||||||||||||||||||||||||||||||||||||||
| 477 | protocol => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||
| 478 | target => 'f.example.com', | ||||||||||||||||||||||||||||||||||||||||||
| 479 | port => 70, | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | priority => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 482 | weight => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 483 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | This returns lines for SRV records following RFC 2782. It takes the following | ||||||||||||||||||||||||||||||||||||||||||
| 486 | special arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | domain - the domain offering service | ||||||||||||||||||||||||||||||||||||||||||
| 489 | service - the well-known service name (http, imaps, finger) | ||||||||||||||||||||||||||||||||||||||||||
| 490 | protocol - tcp or udp | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | target - the host providing service | ||||||||||||||||||||||||||||||||||||||||||
| 493 | port - the port the service listens on | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | priority - numeric priority; lower numbers should be used first | ||||||||||||||||||||||||||||||||||||||||||
| 496 | weight - weight to break priority ties; higher numbers preferred | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | =head2 dkim | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | This returns lines for TXT records for DKIM keys. It takes the following | ||||||||||||||||||||||||||||||||||||||||||
| 501 | arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | domain - the domain | ||||||||||||||||||||||||||||||||||||||||||
| 504 | selector - the key selector | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | ttl - record time to live | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | tags - the DKIM record tags, a hashref | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | Any tag given in the hashref will be included. C<p> is required. | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | Ricardo SIGNES <rjbs@semiotic.systems> | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | This software is copyright (c) 2021 by Ricardo SIGNES. | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 521 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | =cut | ||||||||||||||||||||||||||||||||||||||||||