line |
true |
false |
branch |
58
|
40 |
0 |
if (eval {
do {
require IO::Socket::IP
}
}) { }
|
|
0 |
0 |
elsif (eval {
do {
require IO::Socket::INET6
}
}) { }
|
|
0 |
0 |
elsif (eval {
do {
require IO::Socket::INET
}
}) { }
|
97
|
0 |
80 |
if ($self->{'res'})
|
104
|
0 |
80 |
if (not $force_ipv4 and $io_socket_module_name eq 'IO::Socket::INET')
|
106
|
0 |
0 |
if $force_ipv6
|
109
|
80 |
0 |
unless ($force_ipv4)
|
112
|
80 |
0 |
if ($io_socket_module_name)
|
115
|
0 |
0 |
unless $sock6->close
|
|
0 |
80 |
if ($sock6)
|
117
|
80 |
0 |
unless (eval {
do {
my $sock6;
if ($io_socket_module_name) {
$sock6 = $io_socket_module_name->new('LocalAddr', '::', 'Proto', 'udp');
};
if ($sock6) {
warn "error closing socket: $!" unless $sock6->close;
};
$sock6
}
})
|
120
|
0 |
80 |
if $force_ipv6
|
131
|
80 |
0 |
if ($res)
|
150
|
80 |
0 |
if ($edns and $edns > 512)
|
160
|
158 |
0 |
/^\[(.*)\]:(\d+)\z/ ? :
|
165
|
0 |
80 |
unless (eval {
do {
require Net::DNS;
my $res = $self->{'res'} = 'Net::DNS::Resolver'->new('force_v4', $force_ipv4);
if ($res) {
$self->{'no_resolver'} = 0;
$self->{'force_ipv4'} = $force_ipv4;
$self->{'force_ipv6'} = $force_ipv6;
$self->{'retry'} = 1;
$self->{'retrans'} = 3;
$res->retry(1);
$res->retrans(0);
$res->dnsrch(0);
$res->defnames(0);
$res->tcp_timeout(3);
$res->udp_timeout(3);
$res->persistent_tcp(0);
$res->persistent_udp(0);
my $edns = $self->{'conf'}{'dns_options'}{'edns'};
if ($edns and $edns > 512) {
$res->udppacketsize($edns);
dbg('dns: EDNS, UDP payload size %d', $edns);
};
my(@ns_addr_port) = $self->available_nameservers;
local($1, $2);
@ns_addr_port = map((/^\[(.*)\]:(\d+)\z/ ? $1 : $_), @ns_addr_port);
dbg('dns: nameservers set to %s', join(', ', @ns_addr_port));
$res->nameservers(@ns_addr_port);
};
1
}
})
|
166
|
0 |
0 |
$@ ne '' ? :
|
174
|
0 |
0 |
$self->{'force_ipv6'} ? :
|
|
80 |
0 |
$self->{'force_ipv4'} ? :
|
176
|
0 |
80 |
$self->{'no_resolver'} ? :
|
177
|
80 |
0 |
if (not $self->{'no_resolver'} and defined $Net::DNS::VERSION)
|
207
|
1 |
78 |
if ($self->{'conf'}{'dns_servers'}) { }
|
|
78 |
0 |
elsif ($res) { }
|
212
|
78 |
0 |
$res->UNIVERSAL::can('nameservers') ? :
|
213
|
0 |
78 |
$res->UNIVERSAL::can('port') ? :
|
230
|
0 |
94 |
if (@_) { }
|
|
79 |
15 |
elsif (not $self->{'available_dns_servers'}) { }
|
238
|
94 |
0 |
if ($self->{'force_ipv4'} or $self->{'force_ipv6'})
|
244
|
0 |
172 |
unless /^ \[ (.*) \] : (\d+) \z/sx
|
246
|
172 |
0 |
if ($addr =~ /^$ip4_re\z/o) { }
|
|
0 |
0 |
elsif ($addr =~ /:.*:/) { }
|
247
|
172 |
0 |
unless $self->{'force_ipv6'}
|
249
|
0 |
0 |
unless $self->{'force_ipv4'}
|
254
|
0 |
94 |
if (@filtered_addr_port < @{$self->{'available_dns_servers'};})
|
261
|
0 |
94 |
unless @{$self->{'available_dns_servers'};}
|
267
|
0 |
0 |
if ($lport >= 0 and $lport <= 65535)
|
269
|
0 |
0 |
unless (defined $conf->{'dns_available_portscount'})
|
272
|
0 |
0 |
if (vec $conf->{'dns_available_ports_bitset'}, $lport, 1)
|
289
|
1 |
0 |
unless (defined $available_portscount)
|
291
|
1 |
0 |
unless (defined $ports_bitset)
|
306
|
4 |
252 |
if ($b eq $all_zeroes) { }
|
|
252 |
0 |
elsif ($b eq $all_ones) { }
|
315
|
1 |
0 |
if ($available_portscount) { }
|
325
|
1 |
0 |
if ($available_portscount > 0)
|
333
|
1 |
113 |
if ($cnt > $n) { }
|
337
|
202 |
0 |
if (vec $ports_bitset, $ind, 1)
|
338
|
1 |
201 |
if ($n <= 0) { }
|
356
|
0 |
1 |
$self->{'no_resolver'} ? :
|
357
|
0 |
1 |
if $self->{'no_resolver'}
|
359
|
0 |
1 |
unless $io_socket_module_name
|
362
|
0 |
1 |
if ($self->{'sock'})
|
364
|
0 |
0 |
unless $self->{'sock'}->close
|
374
|
1 |
0 |
if $ns_addr_port[0] =~ /^\[(.*)\]:(\d+)\z/
|
383
|
1 |
0 |
if ($self->{'force_ipv4'}) { }
|
|
0 |
0 |
elsif ($self->{'force_ipv6'}) { }
|
|
0 |
0 |
elsif ($ns_addr =~ /^$ip4_re\z/o) { }
|
|
0 |
0 |
elsif ($ns_addr =~ /:.*:/) { }
|
401
|
0 |
1 |
unless (defined $lport)
|
405
|
0 |
1 |
if ($attempts + 1 > 50)
|
422
|
1 |
0 |
if $sock
|
425
|
0 |
0 |
$io_socket_module_name eq 'IO::Socket::IP' ? :
|
427
|
0 |
0 |
if ($! == 98 or $! == 13) { }
|
430
|
0 |
0 |
if ($self->{'conf'}{'dns_available_portscount'} > 100)
|
438
|
0 |
1 |
unless ($sock)
|
445
|
0 |
1 |
unless $bufsiz = $sock->sockopt(8)
|
447
|
1 |
0 |
if ($bufsiz >= 32768) { }
|
451
|
0 |
0 |
unless $sock->sockopt(8, 32768)
|
453
|
0 |
0 |
unless $newbufsiz = $sock->sockopt(8)
|
459
|
0 |
1 |
unless (eval {
do {
my($bufsiz, $newbufsiz);
die "cannot get a resolver socket rx buffer size: $!" unless $bufsiz = $sock->sockopt(8);
if ($bufsiz >= 32768) {
dbg('dns: resolver socket rx buffer size is %d bytes, local port %d', $bufsiz, $lport);
}
else {
die "cannot set a resolver socket rx buffer size: $!" unless $sock->sockopt(8, 32768);
die "cannot get a resolver socket rx buffer size: $!" unless $newbufsiz = $sock->sockopt(8);
dbg('dns: resolver socket rx buffer size changed from %d to %d bytes, local port %d', $bufsiz, $newbufsiz, $lport);
};
1
}
})
|
460
|
0 |
0 |
$@ ne '' ? :
|
475
|
1 |
12 |
if not $self->{'sock'}
|
515
|
0 |
0 |
if (chr($ic) =~ /^[A-Za-z]\z/)
|
516
|
0 |
0 |
if ($have_rnd_bits < 1)
|
520
|
0 |
0 |
if $rnd & 1
|
533
|
0 |
13 |
if $self->{'no_resolver'}
|
536
|
0 |
13 |
if (not defined $type or $type eq 'PTR')
|
538
|
0 |
0 |
if ($domain =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)
|
543
|
0 |
13 |
unless defined $type
|
544
|
13 |
0 |
unless defined $class
|
549
|
0 |
13 |
if (utf8::is_utf8($domain))
|
554
|
0 |
13 |
if (length $domain > 255) { }
|
|
0 |
13 |
elsif (not $domain =~ /^ (?: [^.]{1,63} \. )+ \z/sx) { }
|
557
|
0 |
0 |
if (not $domain =~ /^ (?: [^.]+ \. )+ \z/sx) { }
|
564
|
0 |
13 |
if ($self->{'conf'}{'dns_options'}{'dns0x20'}) { }
|
574
|
0 |
0 |
$1 eq '\\' ? :
|
582
|
0 |
13 |
unless (eval {
do {
if (utf8::is_utf8($domain)) {
info('dns: new_dns_packet: domain is utf8 flagged: %s', $domain);
};
$domain =~ s/\.*\z/./s;
if (length $domain > 255) {
die "domain name longer than 255 bytes\n";
}
elsif (not $domain =~ /^ (?: [^.]{1,63} \. )+ \z/sx) {
if (not $domain =~ /^ (?: [^.]+ \. )+ \z/sx) {
die "a domain name contains a null label\n";
}
else {
die "a label in a domain name is longer than 63 bytes\n";
};
};
if ($self->{'conf'}{'dns_options'}{'dns0x20'}) {
$domain = dnsext_dns0x20($domain);
}
else {
$domain =~ tr/A-Z/a-z/;
};
$domain =~ s/ ( [\000-\037\177-\377\\] ) /$1 eq '\\' ? "\\$1" : sprintf('\\%03d', ord $1);/egsx;
$packet = 'Net::DNS::Packet'->new($domain, $type, $class);
1
}
})
|
585
|
0 |
0 |
$@ ne '' ? :
|
587
|
0 |
0 |
if $eval_stat =~ /__alarm__ignore__\(.*\)/s
|
593
|
13 |
0 |
if ($packet)
|
599
|
13 |
0 |
if ($udp_payload_size and $udp_payload_size > 512)
|
601
|
13 |
0 |
if ($packet->UNIVERSAL::can('edns')) { }
|
625
|
0 |
26 |
unless @questions <= 1
|
628
|
26 |
0 |
if ($questions[0]) { }
|
640
|
26 |
0 |
unless $self->{'conf'}{'dns_options'}{'dns0x20'}
|
686
|
0 |
13 |
if $self->{'no_resolver'}
|
691
|
0 |
13 |
unless $pkt
|
702
|
13 |
0 |
if ($self->{'sock'} and defined $self->{'sock'}->send($pkt->data, 0)) { }
|
705
|
0 |
0 |
!$self->{'sock'} ? :
|
708
|
0 |
0 |
if ($attempts >= $n_servers)
|
718
|
0 |
13 |
unless $ok
|
739
|
0 |
13 |
if $packetsize < 512
|
742
|
0 |
13 |
unless defined $peeraddr
|
744
|
0 |
13 |
unless $data ne ''
|
747
|
0 |
13 |
unless $answerpkt
|
749
|
0 |
13 |
if (defined $decoded_length and $decoded_length ne '' and $decoded_length != length $data)
|
767
|
0 |
5 |
if $self->{'no_resolver'}
|
768
|
0 |
5 |
unless $self->{'sock'}
|
778
|
1 |
17 |
if (not defined $timeout or $timeout > 0)
|
783
|
0 |
18 |
unless (eval {
do {
my $timer;
if (not defined $timeout or $timeout > 0) {
$timer = $self->{'main'}->time_method('poll_dns_idle');
};
$! = 0;
($nfound, $timeleft) = select($rout = $rin, undef, undef, $timeout);
1
}
})
|
784
|
0 |
0 |
$@ ne '' ? :
|
786
|
0 |
18 |
if (defined $eval_stat) { }
|
|
0 |
18 |
elsif (not defined $nfound or $nfound < 0) { }
|
|
5 |
13 |
elsif (not $nfound) { }
|
788
|
0 |
0 |
if $eval_stat =~ /__alarm__ignore__\(.*\)/s
|
792
|
0 |
0 |
if ($!) { }
|
796
|
0 |
5 |
if (not defined $timeout) { }
|
|
0 |
5 |
elsif ($timeout > 0) { }
|
803
|
0 |
13 |
if $nfound == 0
|
810
|
0 |
13 |
unless (eval {
do {
$packet = $self->bgread
}
})
|
812
|
0 |
0 |
$@ ne '' ? :
|
814
|
0 |
0 |
if $eval_stat =~ /__alarm__ignore__\(.*\)/s
|
818
|
0 |
13 |
if (not $packet) { }
|
825
|
0 |
13 |
if (not $header) { }
|
832
|
10 |
3 |
if ($rcode eq 'NOERROR') { }
|
836
|
0 |
10 |
if ($header->tc)
|
838
|
0 |
0 |
$edns == 512 ? :
|
854
|
13 |
0 |
if ($cb) { }
|
858
|
0 |
0 |
if ($rcode eq 'REFUSED' or $id =~ m[^\d+/NO_QUESTION_IN_PACKET\z]) { }
|
861
|
0 |
0 |
$packet ? :
|
866
|
0 |
0 |
if ($id =~ m[^(\d+)/])
|
870
|
0 |
0 |
if (not @matches) { }
|
915
|
0 |
0 |
if $self->{'no_resolver'}
|
934
|
0 |
0 |
if $timeout < 1
|
941
|
0 |
0 |
unless defined $id
|
947
|
0 |
0 |
if ($now >= $deadline)
|
971
|
0 |
0 |
if $self->{'send_timed_out'}
|
985
|
1 |
40 |
if ($self->{'sock'})
|
987
|
0 |
1 |
unless $self->{'sock'}->close
|
1015
|
0 |
1 |
if (not defined $fno) { }
|