| 1 | package Langertha::Holmgang::Sim::Linux::Dns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: BIND 9 on a simulated Linux server — named.conf, zones, rndc, dig, secondaries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my $T = JSON::MaybeXS::true(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my $F = JSON::MaybeXS::false(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 75 | ▶ | sub _lx { 'Langertha::Holmgang::Sim::Linux' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lx: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 66 | ▶ | sub _text { _lx()->can('_file_text')->(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 46 | ▶ | sub _bind { $_[0]{bind} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 25 | ▶ | sub _svc_name { ( _bind( $_[0] ) || {} )->{service} // 'named' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_svc_name: called CC=3 SCAR=12.7
Condition50%2/4
(_bind($_[0]) || {})->{"service"} // "named"
_bind($_[0]) || {}
MC/DC0%0/1
(_bind($_[0]) || {})->{"service"} // "named"
_bind($_[0])
Truth table50%1/2
A
A= _bind($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 21 | ▶ | sub _conf_path { ( _bind( $_[0] ) || {} )->{conf} // '/etc/bind/named.conf' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conf_path: called CC=3 SCAR=12.7
Condition50%2/4
(_bind($_[0]) || {})->{"conf"} // "/etc/bind/named.conf"
_bind($_[0]) || {}
MC/DC0%0/1
(_bind($_[0]) || {})->{"conf"} // "/etc/bind/named.conf"
_bind($_[0])
Truth table50%1/2
A
A= _bind($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 17 | ▶ | sub _ip_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ip_of: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 17 | my @ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | ▶ | for my $i ( sort keys %{ $dev->{interfaces} || {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'interfaces'} || {}
MC/DC0%0/1
$$dev{'interfaces'} || {}
$$dev{'interfaces'}
Truth table50%1/2
A
A= $$dev{'interfaces'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 17 | ▶ | for my $a ( @{ $dev->{interfaces}{$i}{addr} || [] } ) { push @ip, $1 if $a =~ m{\A([\d.]+)/} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$dev{'interfaces'}{$i}{'addr'} || []
MC/DC0%0/1
$$dev{'interfaces'}{$i}{'addr'} || []
$$dev{'interfaces'}{$i}{'addr'}
Truth table50%1/2
A
A= $$dev{'interfaces'}{$i}{'addr'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 17 | return @ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 25 | ▶ | sub _running { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_running: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 25 | my ($dev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 25 | ▶ | my $s = ( $dev->{services} || {} )->{ _svc_name($dev) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'services'} || {}
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 25 | ▶ | return $s && $s->{active} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$s and $$s{"active"}
MC/DC0%0/2
$s and $$s{"active"}
$s
$$s{"active"}
Truth table33%1/3
A and B
A= $sB= $$s{"active"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # --- named.conf ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 53 | ▶ | sub _conf_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conf_tokens: called CC=9 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 53 | my ( $text, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 53 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 53 | my $line = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 53 | pos($text) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 53 | ▶ | while ( pos($text) < length $text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1085 | ▶ | if ( $text =~ /\G\n/gc ) { $line++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | elsif ( $text =~ /\G[ \t\r]+/gc ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | elsif ( $text =~ m{\G(?://|\#)[^\n]*}gc ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | elsif ( $text =~ m{\G/\*(.*?)\*/}gcs ) { $line += () = $1 =~ /\n/g } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 90 | elsif ( $text =~ /\G"((?:[^"\\\n]|\\.)*)"/gc ) { push @t, { v => $1, q => 1, line => $line, file => $file } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 286 | elsif ( $text =~ /\G([{};])/gc ) { push @t, { v => $1, p => 1, line => $line, file => $file } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 216 | elsif ( $text =~ /\G([^\s{};"]+)/gc ) { push @t, { v => $1, line => $line, file => $file } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | else { die "$file:$line: unexpected character\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 53 | return @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Anweisungen: { words => [...], block => [...]|undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 108 | ▶ | sub _conf_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conf_block: called CC=20 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 108 | my ( $toks, $inner ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 108 | my @st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 108 | ▶ | while (@$toks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 231 | my $t = $toks->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 231 | ▶ | if ( $t->{p} && $t->{v} eq '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$t{"p"} and $$t{"v"} eq "}"
MC/DC50%1/2
$$t{"p"} and $$t{"v"} eq "}"
$$t{"p"}
$$t{"v"} eq "}"
Truth table66%2/3
A and B
A= $$t{"p"}B= $$t{"v"} eq "}"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 52 | ▶ | die "$t->{file}:$t->{line}: unexpected token near '}'\n" unless $inner; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 52 | return \@st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 179 | my ( @w, $block ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 179 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 485 | my $x = shift @$toks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 485 | ▶ | die "$t->{file}:$t->{line}: unexpected end of input\n" unless $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 485 | ▶ | if ( $x->{p} && $x->{v} eq ';' ) { last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$x{"p"} and $$x{"v"} eq ";"
MC/DC100%2/2
$$x{"p"} and $$x{"v"} eq ";"
$$x{"p"}
$$x{"v"} eq ";"
Truth table100%3/3
A and B
A= $$x{"p"}B= $$x{"v"} eq ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 364 | ▶ | if ( $x->{p} && $x->{v} eq '{' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$x{"p"} and $$x{"v"} eq "{"
MC/DC100%2/2
$$x{"p"} and $$x{"v"} eq "{"
$$x{"p"}
$$x{"v"} eq "{"
Truth table100%3/3
A and B
A= $$x{"p"}B= $$x{"v"} eq "{"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 55 | $block = _conf_block( $toks, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 52 | ▶ | my $close = shift @$toks or die "$x->{file}:$x->{line}: unexpected end of input\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 52 | my $semi = $toks->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | die "$close->{file}:$close->{line}: missing ';' before " . ( $semi ? "'$semi->{v}'" : 'end of file' ) . "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 52 | ▶ | unless $semi && $semi->{p} && $semi->{v} eq ';'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$semi and $$semi{"p"} and $$semi{"v"} eq ";"
$semi and $$semi{"p"}
MC/DC0%0/3
$semi and $$semi{"p"} and $$semi{"v"} eq ";"
$semi
$$semi{"p"}
$$semi{"v"} eq ";"
Truth table25%1/4
A and B and C
A= $semiB= $$semi{"p"}C= $$semi{"v"} eq ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 52 | shift @$toks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 52 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 309 | ▶ | if ( $x->{p} && $x->{v} eq '}' ) { die "$x->{file}:$x->{line}: missing ';' before '}'\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$x{"p"} and $$x{"v"} eq "}"
MC/DC50%1/2
$$x{"p"} and $$x{"v"} eq "}"
$$x{"p"}
$$x{"v"} eq "}"
Truth table66%2/3
A and B
A= $$x{"p"}B= $$x{"v"} eq "}"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 306 | push @w, $x->{v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 173 | ▶ | push @st, { words => \@w, block => $block } if @w || $block; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@w or $block
MC/DC0%0/2
@w or $block
@w
$block
Truth table33%1/3
A or B
A= @wB= $block
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 50 | ▶ | die "unexpected end of input\n" if $inner; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 50 | return \@st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 53 | ▶ | sub _conf_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conf_read: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 53 | my ( $dev, $path, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 53 | my $text = _text( $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 53 | ▶ | die "$path: file not found\n" unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 53 | my @toks = _conf_tokens( $text, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 53 | my $st = _conf_block( \@toks, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 50 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 50 | for my $s (@$st) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 66 | ▶ | if ( $s->{words}[0] eq 'include' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 32 | ▶ | die "$path: include loop\n" if ( $depth // 0 ) > 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$depth // 0
MC/DC0%0/1
$depth // 0
$depth
Truth table50%1/2
A
A= $depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 32 | ▶ | push @out, @{ _conf_read( $dev, $s->{words}[1], ( $depth // 0 ) + 1 ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$depth // 0
MC/DC0%0/1
$depth // 0
$depth
Truth table50%1/2
A
A= $depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 34 | else { push @out, $s } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 47 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 18 | ▶ | sub _addr_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_addr_list: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 18 | my ($block) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 18 | ▶ | return [ map { join ' ', @{ $_->{words} } } @{ $block || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$block || []
MC/DC0%0/1
$block || []
$block
Truth table50%1/2
A
A= $block
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # named.conf -> { directory, allow_transfer, zones => { name => {...} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 21 | ▶ | sub parse_conf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_conf: called CC=36 SCAR=41.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 21 | my ( $dev, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 21 | ▶ | $path //= _conf_path($dev); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$path //= _conf_path($dev)
MC/DC0%0/2
$path //= _conf_path($dev)
$path
_conf_path($dev)
Truth table33%1/3
A //= B
A= $pathB= _conf_path($dev)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 21 | my $st = _conf_read( $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 18 | my %c = ( directory => '/var/cache/bind', zones => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 18 | for my $s (@$st) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 31 | my $k = $s->{words}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 31 | ▶ | if ( $k eq 'options' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 13 | ▶ | for my $o ( @{ $s->{block} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$s{'block'} || []
MC/DC0%0/1
$$s{'block'} || []
$$s{'block'}
Truth table50%1/2
A
A= $$s{'block'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 26 | my $ok = $o->{words}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 26 | ▶ | $c{directory} = $o->{words}[1] if $ok eq 'directory'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 26 | ▶ | $c{allow_transfer} = _addr_list( $o->{block} ) if $ok eq 'allow-transfer'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 26 | ▶ | $c{also_notify} = _addr_list( $o->{block} ) if $ok eq 'also-notify'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 26 | ▶ | $c{notify} = $o->{words}[1] if $ok eq 'notify'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | elsif ( $k eq 'zone' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 18 | ▶ | my $name = lc( $s->{words}[1] // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$s{"words"}[1] // ""
MC/DC0%0/1
$$s{"words"}[1] // ""
$$s{"words"}[1]
Truth table50%1/2
A
A= $$s{"words"}[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 18 | ▶ | $name =~ s/\.\z// unless $name eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 18 | ▶ | die "zone '' : missing name\n" unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 18 | ▶ | die "zone '$name': already exists\n" if $c{zones}{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 18 | my %z = ( name => $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 18 | ▶ | for my $o ( @{ $s->{block} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$s{'block'} || []
MC/DC0%0/1
$$s{'block'} || []
$$s{'block'}
Truth table50%1/2
A
A= $$s{'block'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 54 | my $ok = $o->{words}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 54 | ▶ | if ( $ok eq 'type' ) { $z{type} = $o->{words}[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 18 | elsif ( $ok eq 'file' ) { $z{file} = $o->{words}[1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | elsif ( $ok eq 'allow-transfer' ) { $z{allow_transfer} = _addr_list( $o->{block} ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | elsif ( $ok eq 'also-notify' ) { $z{also_notify} = _addr_list( $o->{block} ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | elsif ( $ok eq 'masters' || $ok eq 'primaries' ) { $z{primaries} = _addr_list( $o->{block} ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ok eq "masters" or $ok eq "primaries"
MC/DC0%0/2
$ok eq "masters" or $ok eq "primaries"
$ok eq "masters"
$ok eq "primaries"
Truth table33%1/3
A or B
A= $ok eq "masters"B= $ok eq "primaries"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | elsif ( $ok eq 'notify' ) { $z{notify} = $o->{words}[1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 18 | ▶ | my $t = $z{type} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$z{"type"} // ""
MC/DC0%0/1
$z{"type"} // ""
$z{"type"}
Truth table50%1/2
A
A= $z{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 18 | ▶ | $z{type} = $t eq 'master' ? 'primary' : $t eq 'slave' ? 'secondary' : $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 18 | ▶ | die "zone '$name': type not present\n" unless length $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 18 | ▶ | die "zone '$name': type '$t' not supported\n" unless $z{type} =~ /\A(?:primary|secondary|hint|forward)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 18 | ▶ | die "zone '$name': missing 'file' entry\n" if $z{type} eq 'primary' && !defined $z{file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$z{"type"} eq "primary" and not defined $z{"file"}
MC/DC0%0/2
$z{"type"} eq "primary" and not defined $z{"file"}
$z{"type"} eq "primary"
not defined $z{"file"}
Truth table66%2/3
A and not(B)
A= $z{"type"} eq "primary"B= not defined $z{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 18 | ▶ | die "zone '$name': missing 'primaries' entry\n" if $z{type} eq 'secondary' && !$z{primaries}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$z{"type"} eq "secondary" and not $z{"primaries"}
MC/DC0%0/2
$z{"type"} eq "secondary" and not $z{"primaries"}
$z{"type"} eq "secondary"
not $z{"primaries"}
Truth table66%2/3
A and not(B)
A= $z{"type"} eq "secondary"B= not $z{"primaries"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 18 | $c{zones}{$name} = \%z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 18 | for my $z ( values %{ $c{zones} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 18 | ▶ | $z->{path} = !defined $z->{file} ? undef : $z->{file} =~ m{\A/} ? $z->{file} : "$c{directory}/$z->{file}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 18 | return \%c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # --- Zonendateien ----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 712 | ▶ | sub _ttl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ttl: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 712 | my ($w) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 712 | ▶ | return undef unless defined $w && $w =~ /\A(?:\d+[smhdw]?)+\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $w and $w =~ /\A(?:\d+[smhdw]?)+\z/i
MC/DC50%1/2
defined $w and $w =~ /\A(?:\d+[smhdw]?)+\z/i
defined $w
$w =~ /\A(?:\d+[smhdw]?)+\z/i
Truth table66%2/3
A and B
A= defined $wB= $w =~ /\A(?:\d+[smhdw]?)+\z/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 264 | my %m = ( '' => 1, s => 1, m => 60, h => 3600, d => 86400, w => 604800 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 264 | my $t = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 264 | ▶ | $t += $1 * $m{ lc $2 } while $w =~ /(\d+)([smhdw]?)/gi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 264 | return $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 323 | ▶ | sub _abs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_abs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 323 | my ( $n, $origin ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 323 | ▶ | return $origin if $n eq '@'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 275 | ▶ | return lc( $n =~ /\.\z/ ? $n : "$n.$origin" ) =~ s/\A\.//r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 98 | ▶ | sub _ipv4 { my ($a) = @_; return $a =~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/ && !grep { $_ > 255 } $1, $2, $3, $4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ipv4: called CC=2 SCAR=7.0
Condition66%2/3
$a =~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/ && !grep({$_ > 255;} $1, $2, $3, $4)
MC/DC50%1/2
$a =~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/ && !grep({$_ > 255;} $1, $2, $3, $4)
$a =~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/
!grep({$_ > 255;} $1, $2, $3, $4)
Truth table66%2/3
A && not(B)
A= $a =~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/B= !grep({$_ > 255;} $1, $2, $3, $4)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # Zeilen der Datei in logische Zeilen (Klammern ueber Zeilen), Kommentare weg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 24 | ▶ | sub _zone_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_zone_lines: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 24 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 24 | my ( @out, $cur, $depth, $start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 24 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 24 | for my $raw ( split /\n/, $text ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 321 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 321 | my ( $l, $inq ) = ( '', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 321 | for my $ch ( split //, $raw ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8456 | ▶ | if ( $ch eq '"' ) { $inq = !$inq } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8456 | ▶ | last if $ch eq ';' && !$inq; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ch eq ";" and not $inq
MC/DC50%1/2
$ch eq ";" and not $inq
$ch eq ";"
not $inq
Truth table66%2/3
A and not(B)
A= $ch eq ";"B= not $inq
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 8432 | ▶ | if ( !$inq && ( $ch eq '(' || $ch eq ')' ) ) { $depth += $ch eq '(' ? 1 : -1; $l .= ' '; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
not $inq and $ch eq "(" || $ch eq ")"
$ch eq "(" or $ch eq ")"
MC/DC100%3/3
not $inq and $ch eq "(" || $ch eq ")"
not $inq
$ch eq "("
$ch eq ")"
Truth table100%4/4
not(A) and B or C
A= not $inqB= $ch eq "("C= $ch eq ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8382 | $l .= $ch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 321 | ▶ | if ( defined $cur ) { $cur .= " $l" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 272 | else { ( $cur, $start ) = ( $l, $n ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 321 | ▶ | next if $depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 272 | ▶ | push @out, [ $start, $cur ] if $cur =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 272 | undef $cur; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 24 | ▶ | push @out, [ $start, $cur, 'eof' ] if defined $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 24 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 248 | ▶ | sub _zone_words { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_zone_words: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 248 | my ($l) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 248 | my @w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 248 | ▶ | while ( $l =~ /\G\s*(?:"((?:[^"\\]|\\.)*)"|(\S+))/gc ) { push @w, defined $1 ? { s => $1 } : $2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 248 | return @w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 77 | ▶ | sub _q { my ($s) = @_; return '"' . $s . '"' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_q: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 24 | ▶ | sub parse_zone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_zone: called CC=88 SCAR=62.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 24 | my ( $text, $zone, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 24 | ▶ | $file //= "db.$zone"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$file //= "db.$zone"
MC/DC100%1/1
$file //= "db.$zone"
$file
Truth table100%2/2
A
A= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 24 | my $origin = "$zone."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 24 | my ( $ttl, $last, @rec, @err, @warn, %show ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 24 | ▶ | my $fail = sub { push @err, "zone $zone/IN: loading from master file $file failed: $_[0]"; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 24 | for my $ln ( _zone_lines($text) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 272 | my ( $no, $l, $eof ) = @$ln; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($eof) { $fail->('unexpected end of input'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 272 | ▶ | if ( $l =~ /\A\$TTL\s+(\S+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $ttl = _ttl($1) // do { $fail->("$file:$no: bad ttl"); last }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
_ttl($1) // do {
&$fail("${file}:${no}: bad ttl");
last
}
MC/DC0%0/2
_ttl($1) // do {
&$fail("${file}:${no}: bad ttl");
last
}
_ttl($1)
do {
&$fail("${file}:${no}: bad ttl");
last
}
Truth table33%1/3
A // B
A= _ttl($1)B= do {
&$fail("${file}:${no}: bad ttl");
last
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 24 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ( $l =~ /\A\$ORIGIN\s+(\S+)/ ) { $origin = _abs( $1, $origin ); $origin .= '.' unless $origin =~ /\.\z/; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ( $l =~ /\A\$/ ) { $fail->("$file:$no: unknown \$ directive"); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 248 | my $inherit = $l =~ /\A[ \t]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 248 | my @w = _zone_words($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 248 | my $owner; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 248 | ▶ | if ($inherit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | $owner = $last // do { $fail->("$file:$no: no current owner name"); last }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$last // do {
&$fail("${file}:${no}: no current owner name");
last
}
MC/DC0%0/2
$last // do {
&$fail("${file}:${no}: no current owner name");
last
}
$last
do {
&$fail("${file}:${no}: no current owner name");
last
}
Truth table33%1/3
A // B
A= $lastB= do {
&$fail("${file}:${no}: no current owner name");
last
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 176 | my $o = shift @w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 176 | $owner = _abs( $o, $origin ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 176 | ▶ | $owner .= '.' unless $owner =~ /\.\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 248 | my ( $rttl, $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 248 | ▶ | while ( @w && !ref $w[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@w and not ref $w[0]
MC/DC0%0/2
@w and not ref $w[0]
@w
not ref $w[0]
Truth table33%1/3
A and not(B)
A= @wB= not ref $w[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 520 | ▶ | if ( !defined $rttl && defined _ttl( $w[0] ) ) { $rttl = _ttl( shift @w ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not defined $rttl and defined _ttl($w[0])
MC/DC100%2/2
not defined $rttl and defined _ttl($w[0])
not defined $rttl
defined _ttl($w[0])
Truth table100%3/3
not(A) and B
A= not defined $rttlB= defined _ttl($w[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 248 | elsif ( uc $w[0] eq 'IN' ) { shift @w } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 248 | else { $type = uc shift @w; last } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | unless ( defined $type ) { $fail->("$file:$no: unexpected end of line"); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 248 | $last = $owner; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 248 | my @d = @w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 248 | ▶ | my $bad = sub { $fail->("$file:$no: $_[0]") }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 248 | ▶ | my $name = sub { my $n = _abs( $_[0], $origin ); $n .= '.' unless $n =~ /\.\z/; $n }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 248 | my ( $rd, $sh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 248 | ▶ | if ( $type eq 'A' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 98 | ▶ | unless ( @d == 1 && !ref $d[0] && _ipv4( $d[0] ) ) { $bad->('bad dotted quad'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@d == 1 and not ref $d[0] and _ipv4($d[0])
@d == 1 and not ref $d[0]
MC/DC33%1/3
@d == 1 and not ref $d[0] and _ipv4($d[0])
@d == 1
not ref $d[0]
_ipv4($d[0])
Truth table50%2/4
A and not(B) and C
A= @d == 1B= not ref $d[0]C= _ipv4($d[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 97 | $rd = $d[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | elsif ( $type eq 'AAAA' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | unless ( @d == 1 && !ref $d[0] && $d[0] =~ /\A[0-9a-f:.]+\z/i && $d[0] =~ /:/ ) { $bad->('bad IPv6 address'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
@d == 1 and not ref $d[0] and $d[0] =~ /\A[0-9a-f:.]+\z/i and $d[0] =~ /:/
@d == 1 and not ref $d[0] and $d[0] =~ /\A[0-9a-f:.]+\z/i
@d == 1 and not ref $d[0]
MC/DC0%0/4
@d == 1 and not ref $d[0] and $d[0] =~ /\A[0-9a-f:.]+\z/i and $d[0] =~ /:/
@d == 1
not ref $d[0]
$d[0] =~ /\A[0-9a-f:.]+\z/i
$d[0] =~ /:/
Truth table0%0/5
A and not(B) and C and D
A= @d == 1B= not ref $d[0]C= $d[0] =~ /\A[0-9a-f:.]+\z/iD= $d[0] =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $rd = lc $d[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif ( $type =~ /\A(?:NS|CNAME|PTR)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | unless ( @d == 1 && !ref $d[0] ) { $bad->( @d ? 'extra input text' : 'unexpected end of input' ); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@d == 1 and not ref $d[0]
MC/DC0%0/2
@d == 1 and not ref $d[0]
@d == 1
not ref $d[0]
Truth table33%1/3
A and not(B)
A= @d == 1B= not ref $d[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 75 | $rd = $name->( $d[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif ( $type eq 'MX' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | unless ( @d == 2 && !ref $d[0] && $d[0] =~ /\A\d+\z/ && $d[0] <= 65535 && !ref $d[1] ) { $bad->('not a valid number'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%4/12
@d == 2 and not ref $d[0] and $d[0] =~ /\A\d+\z/ and $d[0] <= 65535 and not ref $d[1]
@d == 2 and not ref $d[0] and $d[0] =~ /\A\d+\z/ and $d[0] <= 65535
@d == 2 and not ref $d[0] and $d[0] =~ /\A\d+\z/
@d == 2 and not ref $d[0]
MC/DC0%0/5
@d == 2 and not ref $d[0] and $d[0] =~ /\A\d+\z/ and $d[0] <= 65535 and not ref $d[1]
@d == 2
not ref $d[0]
$d[0] =~ /\A\d+\z/
$d[0] <= 65535
not ref $d[1]
Truth table16%1/6
A and not(B) and C and D and not(E)
A= @d == 2B= not ref $d[0]C= $d[0] =~ /\A\d+\z/D= $d[0] <= 65535E= not ref $d[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 24 | $rd = ( 0 + $d[0] ) . ' ' . $name->( $d[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | elsif ( $type eq 'SRV' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | unless ( @d == 4 && !grep( { ref } @d ) && !grep( { !/\A\d+\z/ } @d[ 0 .. 2 ] ) ) { $bad->('not a valid number'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@d == 4 and not grep({ref $_;} @d) and not grep({not /\A\d+\z/;} @d[0..2])
@d == 4 and not grep({ref $_;} @d)
MC/DC0%0/3
@d == 4 and not grep({ref $_;} @d) and not grep({not /\A\d+\z/;} @d[0..2])
@d == 4
not grep({ref $_;} @d)
not grep({not /\A\d+\z/;} @d[0..2])
Truth table0%0/4
A and not(B) and not(C)
A= @d == 4B= not grep({ref $_;} @d)C= not grep({not /\A\d+\z/;} @d[0..2])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $rd = join( ' ', map { 0 + $_ } @d[ 0 .. 2 ] ) . ' ' . $name->( $d[3] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | elsif ( $type eq 'TXT' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | unless (@d) { $bad->('unexpected end of input'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 27 | ▶ | my @s = map { ref $_ ? $_->{s} : $_ } @d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 27 | ▶ | if ( grep { length( $_ =~ s/\\(.)/$1/gr ) > 255 } @s ) { $fail->('ran out of space'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 26 | $rd = _q( join '', @s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 26 | $sh = join ' ', map { _q($_) } @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | elsif ( $type eq 'CAA' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | unless ( @d == 3 && $d[0] =~ /\A\d+\z/ ) { $bad->('not a valid number'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@d == 3 and $d[0] =~ /\A\d+\z/
MC/DC0%0/2
@d == 3 and $d[0] =~ /\A\d+\z/
@d == 3
$d[0] =~ /\A\d+\z/
Truth table0%0/3
A and B
A= @d == 3B= $d[0] =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $rd = "$d[0] $d[1] " . _q( ref $d[2] ? $d[2]{s} : $d[2] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | elsif ( $type eq 'SOA' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | unless ( @d == 7 && !grep( { ref } @d ) ) { $bad->( @d < 7 ? 'unexpected end of input' : 'extra input text' ); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@d == 7 and not grep({ref $_;} @d)
MC/DC0%0/2
@d == 7 and not grep({ref $_;} @d)
@d == 7
not grep({ref $_;} @d)
Truth table33%1/3
A and not(B)
A= @d == 7B= not grep({ref $_;} @d)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 24 | my @n = @d[ 2 .. 6 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | unless ( $n[0] =~ /\A\d+\z/ && $n[0] <= 4294967295 ) { $bad->('bad serial number'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$n[0] =~ /\A\d+\z/ and $n[0] <= 4294967295
MC/DC0%0/2
$n[0] =~ /\A\d+\z/ and $n[0] <= 4294967295
$n[0] =~ /\A\d+\z/
$n[0] <= 4294967295
Truth table33%1/3
A and B
A= $n[0] =~ /\A\d+\z/B= $n[0] <= 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ( grep { !defined _ttl($_) } @n[ 1 .. 4 ] ) { $bad->('bad ttl'); last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 24 | $rd = join ' ', $name->( $d[0] ), $name->( $d[1] ), 0 + $n[0], map { _ttl($_) } @n[ 1 .. 4 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | else { $fail->("$file:$no: unknown RR type '$type'"); last } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 246 | ▶ | push @rec, { owner => $owner, ttl => $rttl // $ttl, type => $type, rd => $rd, show => $sh // $rd, line => $no }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$rttl // $ttl
$sh // $rd
MC/DC0%0/2
$rttl // $ttl
$rttl
$ttl
MC/DC0%0/2
$sh // $rd
$sh
$rd
Truth table66%2/3
A // B
A= $rttlB= $ttl
Truth table66%2/3
A // B
A= $shB= $rd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 24 | my $apex = "$zone."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 24 | ▶ | my ($soa) = grep { $_->{type} eq 'SOA' && $_->{owner} eq $apex } @rec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_{'type'} eq 'SOA' && $$_{'owner'} eq $apex
MC/DC50%1/2
$$_{'type'} eq 'SOA' && $$_{'owner'} eq $apex
$$_{'type'} eq 'SOA'
$$_{'owner'} eq $apex
Truth table66%2/3
A && B
A= $$_{'type'} eq 'SOA'B= $$_{'owner'} eq $apex
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 24 | ▶ | if ( !@err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ( !$soa ) { push @err, "zone $zone/IN: has no SOA record" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 22 | my $min = ( split ' ', $soa->{rd} )[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 22 | for my $r ( grep { !defined $_->{ttl} } @rec ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | push @warn, "$file:$r->{line}: no TTL specified; using SOA MINTTL instead" unless @warn && $warn[-1] =~ /no TTL/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@warn and $warn[-1] =~ /no TTL/
MC/DC0%0/2
@warn and $warn[-1] =~ /no TTL/
@warn
$warn[-1] =~ /no TTL/
Truth table0%0/3
A and B
A= @warnB= $warn[-1] =~ /no TTL/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $r->{ttl} = $min; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # Daten ausserhalb der Zone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 24 | my @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 24 | for my $r (@rec) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 246 | ▶ | if ( $r->{owner} eq $apex || $r->{owner} =~ /\.\Q$apex\E\z/ ) { push @in, $r } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$r{"owner"} eq $apex or $$r{"owner"} =~ /\.\Q$apex\E\z/
MC/DC100%2/2
$$r{"owner"} eq $apex or $$r{"owner"} =~ /\.\Q$apex\E\z/
$$r{"owner"} eq $apex
$$r{"owner"} =~ /\.\Q$apex\E\z/
Truth table100%3/3
A or B
A= $$r{"owner"} eq $apexB= $$r{"owner"} =~ /\.\Q$apex\E\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | else { ( my $o = $r->{owner} ) =~ s/\.\z//; push @warn, "$file:$r->{line}: ignoring out-of-zone data ($o)" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 24 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 24 | @in = grep { !$seen{"$_->{owner} $_->{type} $_->{rd}"}++ } @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 24 | my %by; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 24 | push @{ $by{ $_->{owner} } }, $_ for @in; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 24 | ▶ | if ( !@err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 22 | ▶ | push @err, "zone $zone/IN: has no NS records" unless grep { $_->{type} eq 'NS' && $_->{owner} eq $apex } @in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$_{'type'} eq 'NS' && $$_{'owner'} eq $apex
MC/DC50%1/2
$$_{'type'} eq 'NS' && $$_{'owner'} eq $apex
$$_{'type'} eq 'NS'
$$_{'owner'} eq $apex
Truth table66%2/3
A && B
A= $$_{'type'} eq 'NS'B= $$_{'owner'} eq $apex
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 22 | for my $o ( sort keys %by ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 133 | my @t = map { $_->{type} } @{ $by{$o} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 133 | ▶ | if ( grep( { $_ eq 'CNAME' } @t ) && grep { $_ ne 'CNAME' } @t ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
grep {$_ eq "CNAME";} @t and grep {$_ ne "CNAME";} @t
MC/DC100%2/2
grep {$_ eq "CNAME";} @t and grep {$_ ne "CNAME";} @t
grep {$_ eq "CNAME";} @t
grep {$_ ne "CNAME";} @t
Truth table100%3/3
A and B
A= grep {$_ eq "CNAME";} @tB= grep {$_ ne "CNAME";} @t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 4 | ( my $s = $o ) =~ s/\.\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | push @err, "zone $zone/IN: $s: CNAME and other data"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 22 | ▶ | my $has_addr = sub { grep { $_->{type} eq 'A' || $_->{type} eq 'AAAA' } @{ $by{ $_[0] } || [] } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
Condition60%3/5
$$_{'type'} eq 'A' || $$_{'type'} eq 'AAAA'
$by{$_[0]} || []
MC/DC0%0/2
$$_{'type'} eq 'A' || $$_{'type'} eq 'AAAA'
$$_{'type'} eq 'A'
$$_{'type'} eq 'AAAA'
MC/DC100%1/1
$by{$_[0]} || []
$by{$_[0]}
Truth table33%1/3
A || B
A= $$_{'type'} eq 'A'B= $$_{'type'} eq 'AAAA'
Truth table100%2/2
A
A= $by{$_[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 22 | ▶ | my $is_cname = sub { grep { $_->{type} eq 'CNAME' } @{ $by{ $_[0] } || [] } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$by{$_[0]} || []
MC/DC100%1/1
$by{$_[0]} || []
$by{$_[0]}
Truth table100%2/2
A
A= $by{$_[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 22 | ▶ | for my $r ( grep { $_->{type} eq 'NS' || $_->{type} eq 'MX' || $_->{type} eq 'SRV' } @in ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$$_{'type'} eq 'NS' || $$_{'type'} eq 'MX' || $$_{'type'} eq 'SRV'
$$_{"type"} eq "NS" or $$_{"type"} eq "MX"
MC/DC66%2/3
$$_{'type'} eq 'NS' || $$_{'type'} eq 'MX' || $$_{'type'} eq 'SRV'
$$_{"type"} eq "NS"
$$_{"type"} eq "MX"
$$_{'type'} eq 'SRV'
Truth table75%3/4
A or B || C
A= $$_{"type"} eq "NS"B= $$_{"type"} eq "MX"C= $$_{'type'} eq 'SRV'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 66 | my $tg = ( split ' ', $r->{rd} )[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 66 | ▶ | next unless $tg eq $apex || $tg =~ /\.\Q$apex\E\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tg eq $apex or $tg =~ /\.\Q$apex\E\z/
MC/DC0%0/2
$tg eq $apex or $tg =~ /\.\Q$apex\E\z/
$tg eq $apex
$tg =~ /\.\Q$apex\E\z/
Truth table33%1/3
A or B
A= $tg eq $apexB= $tg =~ /\.\Q$apex\E\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 66 | ( my $t = $tg ) =~ s/\.\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 66 | ( my $o = $r->{owner} ) =~ s/\.\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 66 | ▶ | if ( $is_cname->($tg) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | push @{ $r->{type} eq 'NS' ? \@err : \@warn }, "zone $zone/IN: $o/$r->{type} '$t' is a CNAME (illegal)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | elsif ( !$has_addr->($tg) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | if ( $r->{type} eq 'NS' ) { push @err, "zone $zone/IN: NS '$t' has no address records (A or AAAA)" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | else { push @warn, "zone $zone/IN: $o/$r->{type} '$t' has no address records (A or AAAA)" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 22 | ▶ | push @err, "zone $zone/IN: not loaded due to errors." if @err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | else { push @err, "zone $zone/IN: not loaded due to errors." } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 24 | my ( @records, %sh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 24 | for my $r (@in) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 245 | my $k = "$r->{owner} $r->{ttl} IN $r->{type} $r->{rd}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 245 | push @records, $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 245 | ▶ | $sh{$k} = $r->{show} if $r->{show} ne $r->{rd}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | return { ok => @err ? 0 : 1, errors => \@err, warnings => \@warn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 24 | ▶ | ( $soa ? ( serial => 0 + ( split ' ', $soa->{rd} )[2] ) : () ), records => \@records, show => \%sh }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # --- Laden ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 13 | ▶ | sub _log { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 13 | my ( $dev, @l ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 13 | ▶ | my $b = $dev->{bind} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{"bind"} //= {}
MC/DC0%0/1
$$dev{"bind"} //= {}
$$dev{"bind"}
Truth table50%1/2
A
A= $$dev{"bind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 13 | ▶ | my $h = $dev->{hostname} // 'ns'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{"hostname"} // "ns"
MC/DC0%0/1
$$dev{"hostname"} // "ns"
$$dev{"hostname"}
Truth table50%1/2
A
A= $$dev{"hostname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 13 | push @{ $b->{log} }, map {"Oct 20 12:00:00 $h named[812]: $_"} @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | splice @{ $b->{log} }, 0, @{ $b->{log} } - 40 if @{ $b->{log} } > 40; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 16 | ▶ | sub _zone_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_zone_entry: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 16 | my ( $z, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 16 | my %e = ( type => $z->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 16 | ▶ | $e{file} = $z->{path} if defined $z->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 16 | $e{$_} = $z->{$_} for grep { $z->{$_} } qw( allow_transfer also_notify primaries ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 16 | ▶ | $e{notify} = $z->{notify} if defined $z->{notify}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 16 | ▶ | if ($p) { $e{serial} = $p->{serial}; $e{records} = $p->{records}; $e{show} = $p->{show} if %{ $p->{show} || {} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$$p{'show'} || {}
MC/DC0%0/1
$$p{'show'} || {}
$$p{'show'}
Truth table50%1/2
A
A= $$p{'show'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 16 | return \%e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | ▶ | sub _serial_gt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serial_gt: called CC=6 SCAR=19.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | my ( $a, $b ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | ▶ | return 1 if !defined $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | ▶ | return 0 if !defined $a || $a == $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $a or $a == $b
MC/DC50%1/2
not defined $a or $a == $b
not defined $a
$a == $b
Truth table66%2/3
not(A) or B
A= not defined $aB= $a == $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 3 | my $d = ( $a - $b ) % 4294967296; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 3 | ▶ | return $d > 0 && $d < 2147483648 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$d > 0 and $d < 2147483648
MC/DC0%0/2
$d > 0 and $d < 2147483648
$d > 0
$d < 2147483648
Truth table33%1/3
A and B
A= $d > 0B= $d < 2147483648
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 10 | ▶ | sub prepare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=18 SCAR=32.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 10 | my ( $dev, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 10 | ▶ | my $b = $dev->{bind} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | ▶ | return if $b->{zones}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | my %over = map { $_ => $b->{source}{$_} } grep {m{\A/}} keys %{ $b->{source} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$b{'source'} || {}
MC/DC100%1/1
$$b{'source'} || {}
$$b{'source'}
Truth table100%2/2
A
A= $$b{'source'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | ▶ | local $dev->{files} = { %{ $dev->{files} || {} }, %over }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'files'} || {}
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 10 | my $c = parse_conf($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 10 | my %z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 10 | for my $n ( sort keys %{ $c->{zones} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 10 | my $cz = $c->{zones}{$n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 10 | ▶ | my %d = ( %$cz, allow_transfer => $cz->{allow_transfer} // $c->{allow_transfer}, also_notify => $cz->{also_notify} // $c->{also_notify} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$$cz{"allow_transfer"} // $$c{"allow_transfer"}
$$cz{"also_notify"} // $$c{"also_notify"}
MC/DC50%1/2
$$cz{"allow_transfer"} // $$c{"allow_transfer"}
$$cz{"allow_transfer"}
$$c{"allow_transfer"}
MC/DC0%0/2
$$cz{"also_notify"} // $$c{"also_notify"}
$$cz{"also_notify"}
$$c{"also_notify"}
Truth table66%2/3
A // B
A= $$cz{"allow_transfer"}B= $$c{"allow_transfer"}
Truth table33%1/3
A // B
A= $$cz{"also_notify"}B= $$c{"also_notify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 10 | ▶ | if ( $cz->{type} eq 'primary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 5 | ▶ | my $text = ( $b->{source} || {} )->{$n} // _text( $dev, $cz->{path} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($$b{"source"} || {})->{$n} // _text($dev, $$cz{"path"})
$$b{'source'} || {}
MC/DC0%0/2
($$b{"source"} || {})->{$n} // _text($dev, $$cz{"path"})
$$b{'source'}
_text($dev, $$cz{"path"})
Truth table33%1/3
A // B
A= $$b{'source'}B= _text($dev, $$cz{"path"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 5 | ▶ | die "prepare: Zone $n ohne Text\n" unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 5 | my $p = parse_zone( $text, $n, $cz->{file} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | die "prepare: Zone $n laedt nicht: @{ $p->{errors} }\n" unless $p->{ok}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 5 | $z{$n} = _zone_entry( \%d, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | elsif ( $cz->{type} eq 'secondary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | ▶ | my $text = ( $b->{source} || {} )->{$n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$b{'source'} || {}
MC/DC0%0/1
$$b{'source'} || {}
$$b{'source'}
Truth table50%1/2
A
A= $$b{'source'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 5 | ▶ | $z{$n} = _zone_entry( \%d, defined $text ? parse_zone( $text, $n ) : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | _secondary_file( $dev, $z{$n} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | $b->{zones} = \%z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 10 | delete $b->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 10 | ▶ | $dev->{dirs}{$_} //= {} for '/var/cache/bind', '/etc/bind'; # legt das Paket an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{"dirs"}{$_} //= {}
MC/DC0%0/1
$$dev{"dirs"}{$_} //= {}
$$dev{"dirs"}{$_}
Truth table50%1/2
A
A= $$dev{"dirs"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Sekundaerzone: named schreibt die uebertragene Zone in ihre Datei (hier als Text) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 7 | ▶ | sub _secondary_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_secondary_file: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 7 | my ( $dev, $z ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 7 | ▶ | return unless defined $z->{file} && $z->{records}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $$z{"file"} and $$z{"records"}
MC/DC0%0/2
defined $$z{"file"} and $$z{"records"}
defined $$z{"file"}
$$z{"records"}
Truth table33%1/3
A and B
A= defined $$z{"file"}B= $$z{"records"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 7 | ▶ | my $text = '$ORIGIN .' . "\n" . join( '', map {"$_\n"} map { my @f = split ' ', $_, 5; "$f[0]\t$f[1]\tIN $f[3]\t" . ( ( $z->{show} || {} )->{$_} // $f[4] ) } @{ $z->{records} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($$z{"show"} || {})->{$_} // $f[4]
$$z{'show'} || {}
MC/DC0%0/2
($$z{"show"} || {})->{$_} // $f[4]
$$z{'show'}
$f[4]
Truth table33%1/3
A // B
A= $$z{'show'}B= $f[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 7 | $dev->{files}{ $z->{file} } = { content => $text, owner => 'bind', group => 'bind', mode => '0644' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # named laedt: mode reload (alte Zone bleibt bei Fehler), start (frisch), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # reconfig (nur neue Zonen und Optionen), zone (nur diese Zone). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 8 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=30 SCAR=39.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 8 | my ( $dev, $ctx, $mode, $only ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 8 | ▶ | my $b = $dev->{bind} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{"bind"} //= {}
MC/DC0%0/1
$$dev{"bind"} //= {}
$$dev{"bind"}
Truth table50%1/2
A
A= $$dev{"bind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 8 | ▶ | my $old = $b->{zones} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$b{'zones'} || {}
MC/DC0%0/1
$$b{'zones'} || {}
$$b{'zones'}
Truth table50%1/2
A
A= $$b{'zones'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | my $c = eval { parse_conf($dev) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | if ( my $e = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | $e =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 2 | _log( $dev, $e, 'reloading configuration failed: unexpected token' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | return ( $e, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 6 | my %new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | my @notify; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 6 | for my $n ( sort keys %{ $c->{zones} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 6 | my $cz = $c->{zones}{$n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 6 | ▶ | my %d = ( %$cz, allow_transfer => $cz->{allow_transfer} // $c->{allow_transfer}, also_notify => $cz->{also_notify} // $c->{also_notify} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$$cz{"allow_transfer"} // $$c{"allow_transfer"}
$$cz{"also_notify"} // $$c{"also_notify"}
MC/DC0%0/2
$$cz{"allow_transfer"} // $$c{"allow_transfer"}
$$cz{"allow_transfer"}
$$c{"allow_transfer"}
MC/DC0%0/2
$$cz{"also_notify"} // $$c{"also_notify"}
$$cz{"also_notify"}
$$c{"also_notify"}
Truth table33%1/3
A // B
A= $$cz{"allow_transfer"}B= $$c{"allow_transfer"}
Truth table33%1/3
A // B
A= $$cz{"also_notify"}B= $$c{"also_notify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 6 | my $was = $old->{$n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 6 | ▶ | if ( $cz->{type} eq 'primary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 6 | ▶ | my $keep = $mode eq 'reconfig' && $was || defined $only && $only ne $n && $was; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition58%7/12
$mode eq 'reconfig' && $was || defined $only && $only ne $n && $was
$mode eq "reconfig" and $was
defined $only and $only ne $n and $was
defined $only and $only ne $n
MC/DC20%1/5
$mode eq 'reconfig' && $was || defined $only && $only ne $n && $was
$mode eq "reconfig"
$was
defined $only
$only ne $n
$was
Truth table33%3/9
A and B || C and D and E
A= $mode eq "reconfig"B= $wasC= defined $onlyD= $only ne $nE= $was
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 6 | ▶ | if ($keep) { $new{$n} = { %{ _zone_entry( \%d ) }, map { exists $was->{$_} ? ( $_ => $was->{$_} ) : () } qw( serial records show ) }; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 5 | my $text = _text( $dev, $cz->{path} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 5 | ▶ | my $p = defined $text ? parse_zone( $text, $n, $cz->{file} ) : { ok => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | errors => [ "zone $n/IN: loading from master file $cz->{file} failed: file not found", "zone $n/IN: not loaded due to errors." ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 5 | ▶ | if ( $p->{ok} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | _log( $dev, @{ $p->{warnings} }, "zone $n/IN: loaded serial $p->{serial}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | $new{$n} = _zone_entry( \%d, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | ▶ | push @notify, $n if !$was || _serial_gt( $p->{serial}, $was->{serial} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $was or _serial_gt($$p{"serial"}, $$was{"serial"})
MC/DC50%1/2
not $was or _serial_gt($$p{"serial"}, $$was{"serial"})
not $was
_serial_gt($$p{"serial"}, $$was{"serial"})
Truth table66%2/3
not(A) or B
A= not $wasB= _serial_gt($$p{"serial"}, $$was{"serial"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | _log( $dev, @{ $p->{errors} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $new{$n} = $mode eq 'start' || !$was || !$was->{records} ? _zone_entry( \%d ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2 | ▶ | : { %{ _zone_entry( \%d ) }, map { exists $was->{$_} ? ( $_ => $was->{$_} ) : () } qw( serial records show ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$mode eq "start" or not $was or not $$was{"records"}
$mode eq "start" or not $was
MC/DC33%1/3
$mode eq "start" or not $was or not $$was{"records"}
$mode eq "start"
not $was
not $$was{"records"}
Truth table50%2/4
A or not(B) or not(C)
A= $mode eq "start"B= not $wasC= not $$was{"records"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | ▶ | return ( $p->{errors}[0] =~ s/\A.*failed: //r, 0, \%new ) if defined $only && $only eq $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $only and $only eq $n
MC/DC50%1/2
defined $only and $only eq $n
defined $only
$only eq $n
Truth table66%2/3
A and B
A= defined $onlyB= $only eq $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | elsif ( $cz->{type} eq 'secondary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | $new{$n} = { %{ _zone_entry( \%d ) }, $was ? ( map { exists $was->{$_} ? ( $_ => $was->{$_} ) : () } qw( serial records show ) ) : () }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 5 | $b->{zones} = \%new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 5 | _notify( $dev, $ctx, $_ ) for @notify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # neue Sekundaerzonen holen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | for my $n ( grep { $new{$_}{type} eq 'secondary' && !$new{$_}{records} } sort keys %new ) { transfer( $dev, $ctx, $n, 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$new{$_}{'type'} eq 'secondary' && !$new{$_}{'records'}
MC/DC0%0/2
$new{$_}{'type'} eq 'secondary' && !$new{$_}{'records'}
$new{$_}{'type'} eq 'secondary'
!$new{$_}{'records'}
Truth table33%1/3
A && not(B)
A= $new{$_}{'type'} eq 'secondary'B= !$new{$_}{'records'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 5 | return ( '', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 6 | ▶ | sub _devices { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_devices: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 6 | my ($ctx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 6 | ▶ | my $st = $ctx->{state} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$ctx{'state'} || {}
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
Truth table50%1/2
A
A= $$ctx{'state'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 6 | ▶ | return map { [ $_, $st->{$_} ] } grep { ref $st->{$_} eq 'HASH' && ( $st->{$_}{type} // '' ) eq 'linux' } sort keys %$st; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
ref $$st{$_} eq 'HASH' && ($$st{$_}{'type'} // '') eq 'linux'
$$st{$_}{"type"} // ""
MC/DC0%0/2
ref $$st{$_} eq 'HASH' && ($$st{$_}{'type'} // '') eq 'linux'
ref $$st{$_} eq 'HASH'
$$st{$_}{"type"}
Truth table33%1/3
A && B
A= ref $$st{$_} eq 'HASH'B= $$st{$_}{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 6 | ▶ | sub _device_by_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_device_by_ip: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6 | my ( $ctx, $ip ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 6 | ▶ | for my $d ( _devices($ctx) ) { return @$d if $d->[0] eq $ip || grep { $_ eq $ip } _ip_of( $d->[1] ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$d[0] eq $ip or grep {$_ eq $ip;} _ip_of($$d[1])
MC/DC50%1/2
$$d[0] eq $ip or grep {$_ eq $ip;} _ip_of($$d[1])
$$d[0] eq $ip
grep {$_ eq $ip;} _ip_of($$d[1])
Truth table66%2/3
A or B
A= $$d[0] eq $ipB= grep {$_ eq $ip;} _ip_of($$d[1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 4 | ▶ | sub _allowed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_allowed: called CC=11 SCAR=32.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 4 | my ( $list, @ips ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | ▶ | return 1 unless $list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 4 | for my $e (@$list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 4 | ▶ | return 0 if $e eq 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 4 | ▶ | return 1 if $e eq 'any'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 4 | for my $ip (@ips) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5 | ▶ | return 1 if $e eq $ip || $e eq "$ip/32"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$e eq $ip or $e eq "$ip/32"
MC/DC50%1/2
$e eq $ip or $e eq "$ip/32"
$e eq $ip
$e eq "$ip/32"
Truth table66%2/3
A or B
A= $e eq $ipB= $e eq "$ip/32"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 3 | ▶ | if ( $e =~ m{\A([\d.]+)/(\d+)\z} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my ( $n, $len ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | my $m = $len ? ( 0xffffffff << ( 32 - $len ) ) & 0xffffffff : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my $f = sub { my $x = 0; $x = $x * 256 + $_ for split /\./, $_[0]; $x }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | return 1 if ( $f->($ip) & $m ) == ( $f->($n) & $m ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | ▶ | sub _notify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_notify: called CC=18 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | my ( $dev, $ctx, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | ▶ | my $z = $dev->{bind}{zones}{$n} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | return if ( $z->{notify} // '' ) eq 'no'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$z{"notify"} // ""
MC/DC0%0/1
$$z{"notify"} // ""
$$z{"notify"}
Truth table50%1/2
A
A= $$z{"notify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | my $apex = "$n."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | my %ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | ▶ | for my $r ( grep {/\A\Q$apex\E \d+ IN NS /} @{ $z->{records} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$z{'records'} || []
MC/DC0%0/1
$$z{'records'} || []
$$z{'records'}
Truth table50%1/2
A
A= $$z{'records'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 4 | my $tg = ( split ' ', $r )[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | $ip{$_} = 1 for map { ( split ' ', $_ )[-1] } grep {/\A\Q$tg\E \d+ IN A /} @{ $z->{records} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | $ip{$_} = 1 for map { ( split ' ' )[0] } @{ $z->{also_notify} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$z{'also_notify'} || []
MC/DC0%0/1
$$z{'also_notify'} || []
$$z{'also_notify'}
Truth table50%1/2
A
A= $$z{'also_notify'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | my %self = map { $_ => 1 } _ip_of($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | my $host = $ctx->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | for my $ip ( sort grep { !$self{$_} } keys %ip ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2 | ▶ | my ( $name, $sec ) = _device_by_ip( $ctx, $ip ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | ▶ | next if $name eq ( $host // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$host // ""
MC/DC0%0/1
$host // ""
$host
Truth table50%1/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | ▶ | my $sz = ( ( $sec->{bind} || {} )->{zones} || {} )->{$n} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
($$sec{'bind'} || {})->{'zones'} || {}
$$sec{'bind'} || {}
MC/DC0%0/1
($$sec{'bind'} || {})->{'zones'} || {}
$$sec{'bind'}
Truth table50%1/2
A
A= $$sec{'bind'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2 | ▶ | next unless $sz->{type} eq 'secondary' && _running($sec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$sz{"type"} eq "secondary" and _running($sec)
MC/DC0%0/2
$$sz{"type"} eq "secondary" and _running($sec)
$$sz{"type"} eq "secondary"
_running($sec)
Truth table33%1/3
A and B
A= $$sz{"type"} eq "secondary"B= _running($sec)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 2 | _log( $dev, "zone $n/IN: sending notifies (serial $z->{serial})" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | transfer( $sec, { %$ctx, host => $name }, $n, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | ▶ | sub transfer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transfer: called CC=16 SCAR=33.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 3 | my ( $dev, $ctx, $n, $force ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 3 | ▶ | my $z = $dev->{bind}{zones}{$n} or return ( "zone $n: not found", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 3 | my @mine = _ip_of($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | ▶ | for my $p ( map { ( split ' ' )[0] } @{ $z->{primaries} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$z{'primaries'} || []
MC/DC0%0/1
$$z{'primaries'} || []
$$z{'primaries'}
Truth table50%1/2
A
A= $$z{'primaries'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 3 | ▶ | my ( $pn, $pd ) = _device_by_ip( $ctx, $p ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 3 | ▶ | next unless _running($pd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | my $pz = ( ( $pd->{bind} || {} )->{zones} || {} )->{$n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
($$pd{'bind'} || {})->{'zones'} || {}
$$pd{'bind'} || {}
MC/DC0%0/1
($$pd{'bind'} || {})->{'zones'} || {}
$$pd{'bind'}
Truth table50%1/2
A
A= $$pd{'bind'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | ▶ | next unless $pz && $pz->{type} eq 'primary' && $pz->{records}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$pz and $$pz{"type"} eq "primary" and $$pz{"records"}
$pz and $$pz{"type"} eq "primary"
MC/DC0%0/3
$pz and $$pz{"type"} eq "primary" and $$pz{"records"}
$pz
$$pz{"type"} eq "primary"
$$pz{"records"}
Truth table25%1/4
A and B and C
A= $pzB= $$pz{"type"} eq "primary"C= $$pz{"records"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | ▶ | if ( !_allowed( $pz->{allow_transfer}, @mine ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | _log( $dev, "transfer of '$n/IN' from $p#53: failed while receiving responses: REFUSED" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | _log( $pd, "client \@0x7f3a $mine[0]#40112 ($n): zone transfer '$n/AXFR/IN' denied" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 1 | return ( 'REFUSED', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | ▶ | if ( !$force && !_serial_gt( $pz->{serial}, $z->{serial} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$force or _serial_gt($$pz{"serial"}, $$z{"serial"})
MC/DC0%0/2
$force or _serial_gt($$pz{"serial"}, $$z{"serial"})
$force
_serial_gt($$pz{"serial"}, $$z{"serial"})
Truth table66%2/3
A or B
A= $forceB= _serial_gt($$pz{"serial"}, $$z{"serial"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | _log( $dev, "zone $n/IN: zone is up to date (serial $z->{serial})" ) if defined $z->{serial}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | return ( 'up to date', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | @{$z}{qw( serial records )} = @{$pz}{qw( serial records )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if ( $pz->{show} ) { $z->{show} = $pz->{show} } else { delete $z->{show} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | _secondary_file( $dev, $z ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | _log( $dev, "zone $n/IN: transferred serial $pz->{serial}", "transfer of '$n/IN' from $p#53: Transfer completed" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | return ( 'transferred', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | _log( $dev, "zone $n/IN: refresh: retry limit for primary reached" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return ( 'no primary reachable', 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 3 | ▶ | sub service_event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
service_event: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 3 | my ( $dev, $verb, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 3 | ▶ | return if $verb eq 'stop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 3 | ▶ | my ( $o, $ok ) = load( $dev, $ctx, $verb eq 'reload' ? 'reload' : 'start' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 3 | ▶ | die "Job for named.service failed because the control process exited with error code.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $ok and $verb ne "reload"
MC/DC50%1/2
not $ok and $verb ne "reload"
not $ok
$verb ne "reload"
Truth table66%2/3
not(A) and B
A= not $okB= $verb ne "reload"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | . "See \"systemctl status named.service\" and \"journalctl -xeu named.service\" for details.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | if !$ok && $verb ne 'reload'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # --- Befehle ---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 6 | ▶ | sub rndc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rndc: called CC=31 SCAR=49.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 6 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 6 | my @a = grep { !/\A-/ } @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 6 | ▶ | my $cmd = shift(@a) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @a // ""
MC/DC0%0/1
shift @a // ""
shift @a
Truth table50%1/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 6 | ▶ | return ( "rndc: connect failed: 127.0.0.1#953: connection refused", 0 ) unless _running($dev); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 6 | ▶ | my $zone = defined $a[0] ? lc( $a[0] =~ s/\.\z//r ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 6 | ▶ | my $zones = $dev->{bind}{zones} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'bind'}{'zones'} || {}
MC/DC0%0/1
$$dev{'bind'}{'zones'} || {}
$$dev{'bind'}{'zones'}
Truth table50%1/2
A
A= $$dev{'bind'}{'zones'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 6 | ▶ | if ( $cmd eq 'reload' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 4 | ▶ | if ( defined $zone ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | return ( "rndc: 'reload' failed: not found\nno matching zone '$zone' in any view", 0 ) unless $zones->{$zone}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | ▶ | return ( "rndc: 'reload' failed: not a primary zone", 0 ) unless $zones->{$zone}{type} eq 'primary'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | my $before = JSON::MaybeXS->new( canonical => 1 )->encode( $zones->{$zone} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | my ( $o, $ok ) = load( $dev, $ctx, 'zone', $zone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | ▶ | return ( "rndc: 'reload' failed: $o", 0 ) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | return ( JSON::MaybeXS->new( canonical => 1 )->encode( $dev->{bind}{zones}{$zone} ) eq $before ? 'zone reload up-to-date' : 'zone reload queued', 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 3 | my ( $o, $ok ) = load( $dev, $ctx, 'reload' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 3 | ▶ | return ( "rndc: 'reload' failed: unexpected token", 0 ) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 2 | return ( 'server reload successful', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 2 | ▶ | if ( $cmd eq 'reconfig' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | my ( $o, $ok ) = load( $dev, $ctx, 'reconfig' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | ▶ | return ( "rndc: 'reconfig' failed: unexpected token", 0 ) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | return ( '', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | ▶ | if ( $cmd =~ /\A(?:retransfer|refresh|notify|zonestatus)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | ▶ | return ( "rndc: '$cmd' failed: not found\nno matching zone '" . ( $zone // '' ) . "' in any view", 0 ) unless defined $zone && $zones->{$zone}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $zone and $$zones{$zone}
$zone // ""
MC/DC0%0/2
defined $zone and $$zones{$zone}
defined $zone
$$zones{$zone}
MC/DC0%0/1
$zone // ""
$zone
Truth table33%1/3
A and B
A= defined $zoneB= $$zones{$zone}
Truth table0%0/2
A
A= $zone
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | my $z = $zones->{$zone}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | ▶ | if ( $cmd eq 'zonestatus' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | return ( join( "\n", "name: $zone", "type: $z->{type}", ( defined $z->{file} ? "files: $z->{file}" : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | 'serial: ' . ( $z->{serial} // 0 ), 'nodes: ' . scalar( @{ $z->{records} || [] } ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$z{'records'} || []
MC/DC0%0/1
$$z{'records'} || []
$$z{'records'}
Truth table0%0/2
A
A= $$z{'records'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | 'loaded: ' . ( $z->{records} ? 'yes' : 'no' ) ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$z{"serial"} // 0
MC/DC0%0/1
$$z{"serial"} // 0
$$z{"serial"}
Truth table0%0/2
A
A= $$z{"serial"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 1 | ▶ | if ( $cmd eq 'notify' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | return ( "rndc: 'notify' failed: not a primary zone", 0 ) unless $z->{type} eq 'primary'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | _notify( $dev, $ctx, $zone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return ( 'zone notify queued', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 1 | ▶ | return ( "rndc: '$cmd' failed: not a secondary zone", 0 ) unless $z->{type} eq 'secondary'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 1 | transfer( $dev, $ctx, $zone, $cmd eq 'retransfer' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | ▶ | return ( $cmd eq 'refresh' ? 'zone refresh queued' : '', 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if ( $cmd eq 'status' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return ( join( "\n", 'version: BIND 9.18.28-1~deb12u2-Debian (Extended Support Version) <id:>', 'running on localhost: Linux x86_64 6.1.0-26-amd64', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 'number of zones: ' . ( 100 + keys %$zones ) . ' (99 automatic)', 'debug level: 0', 'xfers running: 0', 'server is up and running' ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | return ( '', 1 ) if $cmd eq 'flush' || $cmd eq 'freeze' || $cmd eq 'thaw'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$cmd eq "flush" or $cmd eq "freeze" or $cmd eq "thaw"
$cmd eq "flush" or $cmd eq "freeze"
MC/DC0%0/3
$cmd eq "flush" or $cmd eq "freeze" or $cmd eq "thaw"
$cmd eq "flush"
$cmd eq "freeze"
$cmd eq "thaw"
Truth table0%0/4
A or B or C
A= $cmd eq "flush"B= $cmd eq "freeze"C= $cmd eq "thaw"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | return ( "rndc: '$cmd' failed: unknown command", 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 3 | ▶ | sub checkconf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkconf: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 3 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 3 | my $z = grep { $_ eq '-z' } @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 3 | my ($file) = grep { !/\A-/ } @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | my $c = eval { parse_conf( $dev, $file ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 3 | ▶ | if ( my $e = $@ ) { $e =~ s/\s+\z//; return ( $e, 0 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | ▶ | return ( '', 1 ) unless $z; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 2 | my ( @o, $ok ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | for my $n ( sort keys %{ $c->{zones} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 2 | my $cz = $c->{zones}{$n}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | ▶ | next unless $cz->{type} eq 'primary'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 2 | my $t = _text( $dev, $cz->{path} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | ▶ | my $p = defined $t ? parse_zone( $t, $n, $cz->{file} ) : { ok => 0, errors => ["zone $n/IN: loading from master file $cz->{file} failed: file not found"] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 2 | ▶ | push @o, @{ $p->{warnings} || [] }, $p->{ok} ? "zone $n/IN: loaded serial $p->{serial}" : @{ $p->{errors} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$p{'warnings'} || []
MC/DC100%1/1
$$p{'warnings'} || []
$$p{'warnings'}
Truth table100%2/2
A
A= $$p{'warnings'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | ▶ | $ok = 0 unless $p->{ok}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | return ( join( "\n", @o ), $ok ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | ▶ | sub checkzone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkzone: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 1 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | my @a = grep { !/\A-/ } @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | ▶ | return ( "usage: named-checkzone [-djqvD] [-c class] [-f inputformat] [-F outputformat] zonename [ filename ]", 0 ) unless @a == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | my ( $zone, $file ) = @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | $zone = lc( $zone =~ s/\.\z//r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | my $t = _text( $dev, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | return ( "zone $zone/IN: loading from master file $file failed: file not found\nzone $zone/IN: not loaded due to errors.", 0 ) unless defined $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | my $p = parse_zone( $t, $zone, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | return ( join( "\n", @{ $p->{warnings} }, "zone $zone/IN: loaded serial $p->{serial}", 'OK' ), 1 ) if $p->{ok}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | return ( join( "\n", @{ $p->{warnings} }, @{ $p->{errors} } ), 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # Antwort eines Servers auf eine Frage: ( status, \@answer, \@authority, $aa ) oder Fehlertext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 14 | ▶ | sub _answer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_answer: called CC=17 SCAR=29.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 14 | my ( $srv, $qname, $qtype ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 14 | ▶ | my $zones = ( $srv->{bind} || {} )->{zones} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
($$srv{'bind'} || {})->{'zones'} || {}
$$srv{'bind'} || {}
MC/DC0%0/1
($$srv{'bind'} || {})->{'zones'} || {}
$$srv{'bind'}
Truth table50%1/2
A
A= $$srv{'bind'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | my ($zn) = sort { length $b <=> length $a } grep { $qname eq "$_." || $qname =~ /\.\Q$_\E\.\z/ } keys %$zones; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$qname eq "$_." || $qname =~ /\.\Q$_\E\.\z/
MC/DC0%0/2
$qname eq "$_." || $qname =~ /\.\Q$_\E\.\z/
$qname eq "$_."
$qname =~ /\.\Q$_\E\.\z/
Truth table66%2/3
A || B
A= $qname eq "$_."B= $qname =~ /\.\Q$_\E\.\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 14 | ▶ | return ( 'REFUSED', [], [], 0 ) unless defined $zn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 14 | my $z = $zones->{$zn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 14 | ▶ | return ( 'SERVFAIL', [], [], 0 ) unless $z->{records}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 13 | my @r = @{ $z->{records} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 13 | my ($soa) = grep {/\A\Q$zn\E\. \d+ IN SOA /} @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 13 | ▶ | if ( $qtype eq 'AXFR' ) { return ( 'NOERROR', [ $soa, ( grep { $_ ne $soa } @r ), $soa ], [], 1, $z ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 12 | my ( @ans, %seen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 12 | my $name = $qname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 12 | for ( 1 .. 8 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 13 | my @here = grep { ( split ' ' )[0] eq $name } @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 13 | ▶ | my @t = grep { my $ty = ( split ' ' )[3]; $qtype eq 'ANY' || $ty eq $qtype } @here; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$qtype eq 'ANY' || $ty eq $qtype
MC/DC50%1/2
$qtype eq 'ANY' || $ty eq $qtype
$qtype eq 'ANY'
$ty eq $qtype
Truth table66%2/3
A || B
A= $qtype eq 'ANY'B= $ty eq $qtype
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 13 | ▶ | if (@t) { push @ans, @t; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 2 | my ($cn) = grep { ( split ' ' )[3] eq 'CNAME' } @here; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 2 | ▶ | last unless $cn && !$seen{$name}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cn and not $seen{$name}++
MC/DC50%1/2
$cn and not $seen{$name}++
$cn
not $seen{$name}++
Truth table66%2/3
A and not(B)
A= $cnB= not $seen{$name}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | push @ans, $cn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | $name = ( split ' ', $cn )[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 1 | ▶ | last unless $name eq "$zn." || $name =~ /\.\Q$zn\E\.\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name eq "$zn." or $name =~ /\.\Q$zn\E\.\z/
MC/DC0%0/2
$name eq "$zn." or $name =~ /\.\Q$zn\E\.\z/
$name eq "$zn."
$name =~ /\.\Q$zn\E\.\z/
Truth table33%1/3
A or B
A= $name eq "$zn."B= $name =~ /\.\Q$zn\E\.\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 12 | ▶ | return ( 'NOERROR', \@ans, [], 1, $z ) if @ans; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 1 | ▶ | my $exists = grep { my $o = ( split ' ' )[0]; $o eq $qname || $o =~ /\.\Q$qname\E\z/ } @r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$o eq $qname || $o =~ /\.\Q$qname\E\z/
MC/DC0%0/2
$o eq $qname || $o =~ /\.\Q$qname\E\z/
$o eq $qname
$o =~ /\.\Q$qname\E\z/
Truth table33%1/3
A || B
A= $o eq $qnameB= $o =~ /\.\Q$qname\E\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 1 | ▶ | return ( $exists ? 'NOERROR' : 'NXDOMAIN', [], [$soa], 1, $z ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 12 | ▶ | sub _show { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_show: called CC=4 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 12 | my ( $z, $rr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 12 | my @f = split ' ', $rr, 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 12 | ▶ | my $d = ( $z && $z->{show} || {} )->{$rr} // $f[4]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
($z && $$z{"show"} || {})->{$rr} // $f[4]
$z && $$z{'show'} || {}
$z and $$z{"show"}
MC/DC0%0/3
($z && $$z{"show"} || {})->{$rr} // $f[4]
$z
$$z{"show"}
$f[4]
Truth table0%0/5
A and B // C
A= $zB= $$z{"show"}C= $f[4]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 12 | return ( sprintf( "%s\t\t%s\tIN\t%s\t%s", @f[ 0, 1 ], $f[3], $d ), $d ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # Server waehlen: ( name, dev ) | 'ext' mit dns_servers | Fehlertext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 14 | ▶ | sub _server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_server: called CC=13 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 14 | my ( $dev, $ctx, $srv ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 14 | my $host = $ctx->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 14 | ▶ | if ( !defined $srv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 9 | ($srv) = _lx()->can('_nameservers')->($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 9 | ▶ | return ( undef, undef, ';; no nameservers configured' ) unless defined $srv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 14 | ▶ | if ( $srv eq '127.0.0.1' || $srv eq 'localhost' || $srv eq '::1' || $srv eq ( $host // '' ) || grep { $_ eq $srv } _ip_of($dev) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%10/14
$srv eq "127.0.0.1" or $srv eq "localhost" or $srv eq "::1" or $srv eq ($host // "") or grep {$_ eq $srv;} _ip_of($dev)
$srv eq "127.0.0.1" or $srv eq "localhost" or $srv eq "::1" or $srv eq ($host // "")
$srv eq "127.0.0.1" or $srv eq "localhost" or $srv eq "::1"
$srv eq "127.0.0.1" or $srv eq "localhost"
$host // ""
MC/DC40%2/5
$srv eq "127.0.0.1" or $srv eq "localhost" or $srv eq "::1" or $srv eq ($host // "") or grep {$_ eq $srv;} _ip_of($dev)
$srv eq "127.0.0.1"
$srv eq "localhost"
$srv eq "::1"
$srv eq ($host // "")
grep {$_ eq $srv;} _ip_of($dev)
MC/DC0%0/1
$host // ""
$host
Truth table50%3/6
A or B or C or D or E
A= $srv eq "127.0.0.1"B= $srv eq "localhost"C= $srv eq "::1"D= $srv eq ($host // "")E= grep {$_ eq $srv;} _ip_of($dev)
Truth table50%1/2
A
A= $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 13 | return ( $srv, $dev ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | my ( $n, $d ) = _device_by_ip( $ctx, $srv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | ▶ | return ( $srv, $d ) if $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | return ( $srv, undef, undef, ( $dev->{dns_servers} || {} )->{$srv} ) if ( $dev->{dns_servers} || {} )->{$srv}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$$dev{'dns_servers'} || {}
$$dev{'dns_servers'} || {}
MC/DC0%0/1
$$dev{'dns_servers'} || {}
$$dev{'dns_servers'}
MC/DC0%0/1
$$dev{'dns_servers'} || {}
$$dev{'dns_servers'}
Truth table0%0/2
A
A= $$dev{'dns_servers'}
Truth table0%0/2
A
A= $$dev{'dns_servers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | return ( $srv, undef, ";; communications error to $srv#53: timed out\n;; communications error to $srv#53: timed out\n;; communications error to $srv#53: timed out\n\n; <<>> DiG 9.18.28-1~deb12u2-Debian <<>> \@$srv\n;; global options: +cmd\n;; no servers could be reached" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 14 | ▶ | sub _query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_query: called CC=12 SCAR=33.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 14 | my ( $dev, $ctx, $srv, $qname, $qtype ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 14 | my ( $sname, $sdev, $err, $map ) = _server( $dev, $ctx, $srv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 14 | ▶ | return ( undef, $err ) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 14 | ▶ | if ($map) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my $ip = $map->{ $qname =~ s/\.\z//r }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | return ( { status => defined $ip ? 'NOERROR' : 'NXDOMAIN', ans => defined $ip && $qtype =~ /\A(?:A|ANY)\z/ ? ["$qname 300 IN A $ip"] : [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $ip and $qtype =~ /\A(?:A|ANY)\z/
MC/DC0%0/2
defined $ip and $qtype =~ /\A(?:A|ANY)\z/
defined $ip
$qtype =~ /\A(?:A|ANY)\z/
Truth table0%0/3
A and B
A= defined $ipB= $qtype =~ /\A(?:A|ANY)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | auth => [], aa => 0, server => $sname } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 14 | ▶ | if ( !_running($sdev) || !$sdev->{bind} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_running($sdev) and $$sdev{"bind"}
MC/DC0%0/2
_running($sdev) and $$sdev{"bind"}
_running($sdev)
$$sdev{"bind"}
Truth table33%1/3
A and B
A= _running($sdev)B= $$sdev{"bind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | return ( undef, ";; communications error to $sname#53: connection refused\n" x 3 . ";; no servers could be reached" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 14 | my ( $st, $ans, $auth, $aa, $z ) = _answer( $sdev, $qname, $qtype ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 14 | ▶ | if ( $qtype eq 'AXFR' && $st eq 'NOERROR' && !_allowed( $z->{allow_transfer}, _ip_of($dev), ( $sdev == $dev ? ('127.0.0.1') : () ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$qtype eq "AXFR" and $st eq "NOERROR" and not _allowed($$z{"allow_transfer"}, _ip_of($dev), $sdev == $dev ? "127.0.0.1" : ())
$qtype eq "AXFR" and $st eq "NOERROR"
MC/DC33%1/3
$qtype eq "AXFR" and $st eq "NOERROR" and not _allowed($$z{"allow_transfer"}, _ip_of($dev), $sdev == $dev ? "127.0.0.1" : ())
$qtype eq "AXFR"
$st eq "NOERROR"
not _allowed($$z{"allow_transfer"}, _ip_of($dev), $sdev == $dev ? "127.0.0.1" : ())
Truth table50%2/4
A and B and not(C)
A= $qtype eq "AXFR"B= $st eq "NOERROR"C= not _allowed($$z{"allow_transfer"}, _ip_of($dev), $sdev == $dev ? "127.0.0.1" : ())
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 1 | return ( { status => 'XFRFAIL', ans => [], auth => [], server => $sname } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 13 | return ( { status => $st, ans => $ans, auth => $auth, aa => $aa, zone => $z, server => $sname } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | sub _rev { my ($ip) = @_; return join( '.', reverse split /\./, $ip ) . '.in-addr.arpa.' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rev: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 13 | ▶ | sub dig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dig: called CC=32 SCAR=41.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 13 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 13 | my ( $srv, $name, $type, $short, $answer_only, $rev ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 13 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 13 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 31 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 31 | ▶ | if ( $x =~ /\A@(.+)\z/ ) { $srv = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 9 | elsif ( $x eq '+short' ) { $short = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | elsif ( $x eq '+noall' ) { $answer_only //= 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$answer_only //= 0
MC/DC0%0/1
$answer_only //= 0
$answer_only
Truth table0%0/2
A
A= $answer_only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | elsif ( $x eq '+answer' ) { $answer_only = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | elsif ( $x =~ /\A\+/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | elsif ( $x eq '-x' ) { $name = _rev( shift(@a) // '' ); $type //= 'PTR' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
shift @a // ""
$type //= "PTR"
MC/DC0%0/1
shift @a // ""
shift @a
MC/DC0%0/1
$type //= "PTR"
$type
Truth table0%0/2
A
A= shift @a
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | elsif ( $x eq '-t' ) { $type = uc( shift(@a) // '' ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @a // ""
MC/DC0%0/1
shift @a // ""
shift @a
Truth table0%0/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | elsif ( $x eq '-c' ) { shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | elsif ( $x =~ /\A-[46]\z/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 4 | ▶ | elsif ( $x =~ /\A(?:A|AAAA|MX|NS|TXT|SOA|CNAME|PTR|SRV|CAA|ANY|AXFR)\z/i && !defined $type ) { $type = uc $x } # Typ vor oder nach dem Namen (dig TXT name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x =~ /\A(?:A|AAAA|MX|NS|TXT|SOA|CNAME|PTR|SRV|CAA|ANY|AXFR)\z/i and not defined $type
MC/DC50%1/2
$x =~ /\A(?:A|AAAA|MX|NS|TXT|SOA|CNAME|PTR|SRV|CAA|ANY|AXFR)\z/i and not defined $type
$x =~ /\A(?:A|AAAA|MX|NS|TXT|SOA|CNAME|PTR|SRV|CAA|ANY|AXFR)\z/i
not defined $type
Truth table66%2/3
A and not(B)
A= $x =~ /\A(?:A|AAAA|MX|NS|TXT|SOA|CNAME|PTR|SRV|CAA|ANY|AXFR)\z/iB= not defined $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | elsif ( uc $x eq 'IN' ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 13 | elsif ( !defined $name ) { $name = $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | else { $type = uc $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 13 | ▶ | $name //= '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$name //= "."
MC/DC0%0/1
$name //= "."
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 13 | ▶ | $type //= 'A'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$type //= "A"
MC/DC100%1/1
$type //= "A"
$type
Truth table100%2/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 13 | my $q = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 13 | ▶ | $q .= '.' unless $q =~ /\.\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 13 | my ( $r, $err ) = _query( $dev, $ctx, $srv, $q, $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 13 | ▶ | return ( $err, 0 ) unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 13 | my @show = map { [ _show( $r->{zone}, $_ ) ] } @{ $r->{ans} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 13 | ▶ | if ( $r->{status} eq 'XFRFAIL' ) { return ( "; Transfer failed.", 0 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 12 | ▶ | if ($short) { return ( join( "\n", map { $_->[1] } @show ), 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 3 | ▶ | if ( $type eq 'AXFR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | return ( join( "\n", "; <<>> DiG 9.18.28-1~deb12u2-Debian <<>> " . join( ' ', @$av ), ';; global options: +cmd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ( map { $_->[0] } @show ), ";; XFR size: " . scalar(@show) . ' records (messages 1, bytes 1024)' ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 3 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 3 | ▶ | if ( !defined $answer_only ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 3 | ▶ | my $rec = $r->{aa} ? 'qr aa rd' : 'qr rd ra'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | push @l, "; <<>> DiG 9.18.28-1~deb12u2-Debian <<>> " . join( ' ', @$av ), ';; global options: +cmd', ';; Got answer:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | ";; ->>HEADER<<- opcode: QUERY, status: $r->{status}, id: 4711", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 3 | ";; flags: $rec; QUERY: 1, ANSWER: " . scalar(@show) . ', AUTHORITY: ' . scalar( @{ $r->{auth} } ) . ', ADDITIONAL: 1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 3 | ▶ | push @l, ';; WARNING: recursion requested but not available' if $r->{aa} || $r->{status} eq 'REFUSED'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$r{"aa"} or $$r{"status"} eq "REFUSED"
MC/DC50%1/2
$$r{"aa"} or $$r{"status"} eq "REFUSED"
$$r{"aa"}
$$r{"status"} eq "REFUSED"
Truth table66%2/3
A or B
A= $$r{"aa"}B= $$r{"status"} eq "REFUSED"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 3 | push @l, '', ';; QUESTION SECTION:', ";$q\t\t\tIN\t$type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 3 | ▶ | push @l, '', ';; ANSWER SECTION:', map { $_->[0] } @show if @show; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 3 | ▶ | push @l, '', ';; AUTHORITY SECTION:', map { ( _show( $r->{zone}, $_ ) )[0] } @{ $r->{auth} } if @{ $r->{auth} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 3 | push @l, '', ';; Query time: 0 msec', ";; SERVER: $r->{server}#53($r->{server}) (UDP)", ';; WHEN: Tue Oct 20 12:00:00 CEST 2026', ';; MSG SIZE rcvd: 120'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | else { push @l, map { $_->[0] } @show } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 3 | return ( join( "\n", @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | ▶ | sub host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=27 SCAR=41.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1 | my ( $type, @a ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | my @w = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 1 | ▶ | while (@w) { my $x = shift @w; if ( $x eq '-t' ) { $type = uc( shift(@w) // '' ) } elsif ( $x !~ /\A-/ ) { push @a, $x } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%1/2
shift @w // ""
MC/DC0%0/1
shift @w // ""
shift @w
Truth table50%1/2
A
A= shift @w
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | my ( $name, $srv ) = @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 1 | ▶ | return ( 'Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time] [-R number] [-m flag] [-p port] hostname [server]', 0 ) unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 1 | my $q = lc $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 1 | ▶ | $q = _rev($q) if $q =~ /\A[\d.]+\z/ && _ipv4($q); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$q =~ /\A[\d.]+\z/ and _ipv4($q)
MC/DC0%0/2
$q =~ /\A[\d.]+\z/ and _ipv4($q)
$q =~ /\A[\d.]+\z/
_ipv4($q)
Truth table33%1/3
A and B
A= $q =~ /\A[\d.]+\z/B= _ipv4($q)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | ▶ | $q .= '.' unless $q =~ /\.\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | ▶ | my @types = defined $type ? ($type) : $q =~ /in-addr\.arpa\.\z/ ? ('PTR') : qw( A AAAA MX ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 1 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | for my $t (@types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | my ( $r, $err ) = _query( $dev, $ctx, $srv, $q, $t ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 1 | ▶ | return ( ";; connection timed out; no servers could be reached", 0 ) unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 1 | ▶ | if ( $r->{status} ne 'NOERROR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my %c = ( NXDOMAIN => 3, SERVFAIL => 2, REFUSED => 5 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | return ( "Host $name not found: $c{ $r->{status} }($r->{status})", 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 1 | for my $rr ( @{ $r->{ans} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1 | my ( $o, undef, undef, $ty, $d ) = split ' ', $rr, 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 1 | ▶ | $d = ( ( $r->{zone} || {} )->{show} || {} )->{$rr} // $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
(($$r{"zone"} || {})->{"show"} || {})->{$rr} // $d
($$r{'zone'} || {})->{'show'} || {}
$$r{'zone'} || {}
MC/DC0%0/2
(($$r{"zone"} || {})->{"show"} || {})->{$rr} // $d
$$r{'zone'}
$d
Truth table33%1/3
A // B
A= $$r{'zone'}B= $d
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 1 | $o =~ s/\.\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 1 | ▶ | push @l, $ty eq 'A' ? "$o has address $d" : $ty eq 'AAAA' ? "$o has IPv6 address $d" : $ty eq 'MX' ? "$o mail is handled by $d" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | : $ty eq 'CNAME' ? "$o is an alias for $d" : $ty eq 'TXT' ? "$o descriptive text $d" : $ty eq 'PTR' ? "$o domain name pointer $d" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | : $ty eq 'NS' ? "$o name server $d" : "$o has $ty record $d"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 1 | ▶ | push @l, "$name has no $t record" if defined $type && !@{ $r->{ans} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $type and not @{$$r{"ans"};}
MC/DC0%0/2
defined $type and not @{$$r{"ans"};}
defined $type
not @{$$r{"ans"};}
Truth table33%1/3
A and not(B)
A= defined $typeB= not @{$$r{"ans"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | return ( join( "\n", @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||