Branch Coverage

blib/lib/Net/DNS/Lite.pm
Criterion Covered Total %
branch 103 178 57.8


line true false branch
120 3 3 if (@{$$self{'server'};} == 0)
121 3 0 if (-e '/etc/resolv.conf') { }
138 0 11 unless Socket::inet_aton($_)
166 6 1 $qname =~ tr/.// >= $$self{'ndots'} ? :
0 7 $opt{'search'} ? :
2 7 $qname =~ s/\.$// ? :
171 0 9 $opt{'accept'} ? :
176 0 9 defined $opt{'timeout'} ? :
183 3 9 unless @search
190 1 8 unless my $res = $self->request($name, $qtype, $class, $timeout_at)
197 34 0 if $name eq lc $$_[0]
201 6 2 if (@rr)
206 0 0 if $name eq lc $$_[0]
210 0 2 if (@rr) { }
0 2 elsif ($cname) { }
211 0 0 unless $depth--
238 9 0 unless (defined $$self{'cache'})
243 2 7 if ($cache)
244 1 1 if (my $value = $cache->get($cache_key))
246 1 0 if time < $expires_at
252 5 3 if not $$self{'sock_v4'} or $$self{'pid'} != $$
268 0 10 if $total_timeout_at < $server_timeout_at
270 0 10 if ($server_timeout_at <= $now)
279 0 10 unless (send $$self{'sock_v4'}, $req_pkt, 0, scalar sockaddr_in(53, $server))
288 3 10 if ($select_timeout <= 0)
289 0 3 if $total_timeout_at <= $now
292 0 10 if $select_timeout <= 0
297 3 7 unless $nfound > 0
298 0 7 unless my $from = recv($$self{'sock_v4'}, my $res_pkt, 1024, 0)
301 0 7 unless ($from_port == 53 and grep {$from_addr eq $_;} @{$$self{'server'};})
305 0 7 unless $res = dns_unpack($res_pkt)
307 7 0 if ($$res{'id'} == $$req{'id'})
308 0 7 if $retry != 0
310 1 6 if ($cache)
315 1 0 @{$$res{'an'};} ? :
326 1 0 if $pkt_sent
336 5 0 if socket $$self{'sock_v4'}, 2, 2, 0
343 0 5 unless $got_socket
357 0 8 if (@{$$self{'reuse_q'};} >= 30000) { }
366 8 0 unless defined $$self{'reuse_h'}{$id}
391 11 15 if (/^\s*nameserver\s+(\S+)\s*$/i) { }
3 12 elsif (/^\s*domain\s+(\S*)\s*$/i) { }
0 12 elsif (/^\s*search\s+(.*?)\s*$/i) { }
0 12 elsif (/^\s*sortlist\s+(.*?)\s*$/i) { }
3 9 elsif (/^\s*options\s+(.*?)\s*$/i) { }
393 11 0 if (my $ipn = parse_address($ip)) { }
406 2 5 if (/^timeout:(\d+)$/) { }
2 3 elsif (/^attempts:(\d+)$/) { }
0 3 elsif (/^ndots:(\d+)$/) { }
419 3 4 if ($timeout or $attempts)
429 0 3 unless open my $fh, '<', $resolv_conf
441 0 8 $$_[1] > 0 ? :
0 8 $$_[2] > 0 ? :
454 0 8 unless $$req{'qd'}
467 8 0 unless $$req{'an'}
468 8 0 unless $$req{'ns'}
469 8 0 unless $$req{'ar'}
470 0 8 unless $$req{'qd'}
472 8 0 unless $$req{'an'}
473 8 0 unless $$req{'ns'}
474 8 0 unless $$req{'ar'}
489 0 215 if ++$cnt >= 256
493 42 173 if ($len >= 192) { }
122 51 elsif ($len) { }
495 38 4 if $ptr > $ofs
501 13 38 if $ptr > $ofs
581 0 15 if (my $addr = parse_ipv6($text)) { }
590 4 14 unless $_[0] =~ /^ (?: 0x[0-9a-fA-F]+ | 0[0-7]* | [1-9][0-9]* ) (?:\. (?: 0x[0-9a-fA-F]+ | 0[0-7]* | [1-9][0-9]* ) ){0,3}$/x
594 2 54 /^0/ ? :
597 0 14 if grep(($_ >= 256), @_[0 .. @_ - 2])
600 0 14 if $_[-1] >= 2 ** (8 * (4 - $#_))
611 15 1 if $n < 2 or $n > 8
615 1 0 unless (defined $t)
619 0 1 defined $h ? :
623 0 1 if (@t and $t[-1] =~ /\./)
624 0 0 if $n > 6
626 0 0 unless my $ipn = parse_ipv4(pop @t)
633 0 1 unless @h + @t == 8 or $_[0] =~ /::/
636 0 1 if grep((!/^[0-9a-fA-F]{1,4}$/), @h, @t)
653 0 4 if (my $address = parse_address($name))
656 0 4 @_ ? :
663 3 0 if defined $address
674 0 0 if ($_[0] =~ /^\x00\x00\x00\x00\x00\x00\x00\x00/)
675 0 0 if (v0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 eq $_[0]) { }
0 0 elsif (v0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1 eq $_[0]) { }
0 0 elsif (v0.0.0.0.0.0.0.0.0.0.0.0 eq substr($_[0], 0, 12)) { }
0 0 elsif (v0.0.0.0.0.0.0.0.0.0.255.255 eq substr($_[0], 0, 12)) { }
0 0 elsif (v0.0.0.0.0.0.0.0.255.255.0.0 eq substr($_[0], 0, 12)) { }
694 0 0 unless $ip =~ s/(?:^|:) 0:0:0:0:0:0:0 (?:$|:)/::/x or $ip =~ s/(?:^|:) 0:0:0:0:0:0 (?:$|:)/::/x or $ip =~ s/(?:^|:) 0:0:0:0:0 (?:$|:)/::/x or $ip =~ s/(?:^|:) 0:0:0:0 (?:$|:)/::/x or $ip =~ s/(?:^|:) 0:0:0 (?:$|:)/::/x or $ip =~ s/(?:^|:) 0:0 (?:$|:)/::/x