DNS/Resolver/Base.pm

filter: Statementstmt 100% 652 / 652 Branchbran 100% 274 / 276 (2 uncoverable) Conditioncond 100% 70 / 70 MC/DCmcdc 100% 40 / 40 Subroutinesub 100% 90 / 90 Podpod 86.2% 24 / 29 (1 uncoverable) totaltotal 99.6% 1150 / 1157 (3 uncoverable) CC 192 SCAR 18.7
CC
192
Cov
100%
_send_udp
18.0
nameservers
14.0
_send_tcp
11.0
CRAP 6.5
« DNS/RR/TSIG.pm ↑ Summary DNS/DomainName.pm »
1 package Net::DNS::Resolver::Base;
2  
3 184 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 184 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 92 our $VERSION = (qw$Id: Base.pm 2057 2026-07-16 10:05:04Z willem $)[2];
6  
7  
8 #
9 # Implementation notes wrt IPv6 support when using perl before 5.20.0.
10 #
11 # In general we try to be gracious to those stacks that do not have IPv6 support.
12 # The socket code is conditionally compiled depending upon the availability of
13 # the IO::Socket::IP package.
14 #
15 # We have chosen not to use mapped IPv4 addresses, there seem to be issues
16 # with this; as a result we use separate sockets for each family type.
17 #
18 # inet_pton is not available on WIN32, so we only use the getaddrinfo
19 # call to translate IP addresses to socketaddress.
20 #
21 # The configuration options force_v4, force_v6, prefer_v4 and prefer_v6
22 # are provided to control IPv6 behaviour for test purposes.
23 #
24 # Olaf Kolkman, RIPE NCC, December 2003.
25 # [Revised March 2016, June 2018]
26  
27  
28 184 ▶use constant OS_SPEC => "Net::DNS::Resolver::$^O";
Subroutine BEGIN: called CC=1 SCAR=0.0
29 184 ▶use constant OS_UNIX => "Net::DNS::Resolver::UNIX";
Subroutine BEGIN: called CC=1 SCAR=0.0
30 184 ▶use constant OS_CONF => grep( eval "require $_", OS_SPEC ), OS_UNIX; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
31 184 ▶use base (OS_CONF)[0];
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33  
34 92 ▶use constant USE_SOCKET_IP => defined eval 'use IO::Socket::IP 0.38; 1;'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
35 92 require IO::Socket::INET unless USE_SOCKET_IP;
36  
37 92 ▶use constant IPv6 => USE_SOCKET_IP;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39  
40 # If SOCKSified Perl, use TCP instead of UDP and keep the socket open.
41 92 ▶use constant SOCKS => scalar eval { require Config; $Config::Config{usesocks}; };
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43  
44 # Allow taint tests to be optimised away when appropriate.
45 92 ▶use constant TFLAG => eval { ${^TAINT} };
Subroutine BEGIN: called CC=1 SCAR=0.0
46 92 ▶use constant TAINT => TFLAG && defined eval { require Scalar::Util; };
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48  
49 92 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 92 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 92 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 92 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 92 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 92 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 {
57 92 ▶ no strict 'subs'; ## no critic ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
58 92 ▶ use constant AI_NUMERICHOST => Socket::AI_NUMERICHOST;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 92 ▶ use constant IPPROTO_UDP => Socket::IPPROTO_UDP;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 }
61  
62 92 ▶use Net::DNS::RR;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 92 ▶use Net::DNS::Packet;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 92 ▶use constant PACKETSZ => 512;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67  
68 #
69 # Set up a closure to be our class data.
70 #
71 {
72 92 my $defaults = bless {
73 nameservers => [qw(::1 127.0.0.1)],
74 nameserver4 => ['127.0.0.1'],
75 nameserver6 => ['::1'],
76 port => 53,
77 srcaddr4 => '0.0.0.0',
78 srcaddr6 => '::',
79 srcport => 0,
80 searchlist => [],
81 retrans => 5,
82 retry => 4,
83 usevc => ( SOCKS ? 1 : 0 ),
84 igntc => 0,
85 recurse => 1,
86 defnames => 1,
87 dnsrch => 1,
88 ndots => 1,
89 debug => 0,
90 tcp_timeout => 120,
91 udp_timeout => 30,
92 persistent_tcp => ( SOCKS ? 1 : 0 ),
93 persistent_udp => 0,
94 dnssec => 0,
95 adflag => 0, # see RFC6840, 5.7
96 cdflag => 0, # see RFC6840, 5.9
97 udppacketsize => 0, # value bounded below by PACKETSZ
98 force_v4 => 0,
99 force_v6 => 0,
100 prefer_v4 => 0,
101 prefer_v6 => 0,
102 },
103 __PACKAGE__;
104  
105  
106 252 ▶ sub _defaults { return $defaults; }
Subroutine _defaults: called CC=1 SCAR=0.0
107 }
108  
109  
110 92 my %warned;
111  
112 7 ▶sub _deprecate {
Subroutine _deprecate: called CC=2 SCAR=6.9
113 7 my ( undef, @note ) = @_;
114 7 ▶ carp join ' ', 'deprecated method;', "@note" unless $warned{"@note"}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $warned{join $", @note}++ 6 1 7
115 7 return;
116 }
117  
118  
119 10 ▶sub _untaint { ## no critic # recurses into user list arguments
Subroutine _untaint: called CC=1 SCAR=0.0
120 10 return TAINT ? map { ref($_) ? [_untaint(@$_)] : do { /^(.*)$/; $1 } } @_ : @_;
121 }
122  
123  
124 # These are the attributes that the user may specify in the new() constructor.
125 my %public_attr = (
126 3680 map { $_ => $_ } keys %{&_defaults},
127 qw(domain nameserver srcaddr),
128 92 map { $_ => 0 } qw(nameserver4 nameserver6 srcaddr4 srcaddr6),
129 );
130  
131  
132 92 my $initial;
133  
134 92 ▶sub new {
Subroutine new: called CC=10 SCAR=23.0
Pod documented
135 92 my ( $class, %args ) = @_;
136  
137 92 my $self;
138 92 my $base = $class->_defaults;
139 92 my $init = $initial;
140 92 ▶ $initial ||= [%$base];
Condition100%2/2
$initial ||= [%$base]
l!l
839
MC/DC100%1/1
$initial ||= [%$base]
$initial
Truth table100%2/2
A
A= $initial
Aresult
11
00
141 92 ▶ if ( my $file = $args{config_file} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $file = $args{'config_file'}) { } 4 88 92
elsif ($init) { } 80 8 88
142 4 my $conf = bless {@$initial}, $class;
143 4 $conf->_read_config_file($file); # user specified config
144 2 $self = bless {_untaint(%$conf)}, $class;
145 2 ▶ %$base = %$self unless $init; # define default configuration
Branch: 1 branch
BranchTrueFalseTotal
unless $init 1 1 2
146  
147 } elsif ($init) {
148 80 $self = bless {%$base}, $class;
149  
150 } else {
151 8 $class->_init(); # define default configuration
152 8 $self = bless {%$base}, $class;
153 }
154  
155 90 ▶ while ( my ( $attr, $value ) = each %args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 76 86 162
156 76 ▶ next unless $public_attr{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $public_attr{$attr} 2 74 76
157 74 my $ref = ref($value);
158 74 ▶ croak "usage: $class->new( $attr => [...] )"
Branch: 1 branch
BranchTrueFalseTotal
if $ref and $ref ne "ARRAY" 4 70 74
Condition100%3/3
$ref and $ref ne "ARRAY"
!ll&&!rl&&r
46244
MC/DC100%2/2
$ref and $ref ne "ARRAY"
$ref $ref ne "ARRAY"
Truth table100%3/3
A and B
A= $refB= $ref ne "ARRAY"
ABresult
0X0
100
111
159 if $ref && ( $ref ne 'ARRAY' );
160 70 ▶ $self->$attr( $ref ? @$value : $value );
Branch: 1 branch
BranchTrueFalseTotal
$ref ? : 24 46 70
161 }
162  
163 86 return $self;
164 }
165  
166  
167 92 my %resolv_conf = ( ## map traditional resolv.conf option names
168 attempts => 'retry',
169 inet6 => 'prefer_v6',
170 timeout => 'retrans',
171 );
172  
173 92 my %res_option = ( ## any resolver attribute plus those listed above
174 %public_attr,
175 %resolv_conf,
176 );
177  
178 10 ▶sub _option {
Subroutine _option: called CC=3 SCAR=11.0
179 10 my ( $self, $name, @value ) = @_;
180 10 ▶ my $attribute = $res_option{lc $name} || return;
Condition100%2/2
$res_option{lc $name} || (return)
l!l
73
MC/DC100%1/1
$res_option{lc $name} || (return)
$res_option{lc $name}
Truth table100%2/2
A
A= $res_option{lc $name}
Aresult
11
00
181 7 ▶ push @value, 1 unless scalar @value;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @value 3 4 7
182 7 return $self->$attribute(@value);
183 }
184  
185  
186 8 ▶sub _read_env { ## read resolver config environment variables
Subroutine _read_env: called CC=6 SCAR=17.9
187 8 my $self = shift;
188  
189 8 ▶ $self->searchlist( map {split} $ENV{LOCALDOMAIN} ) if defined $ENV{LOCALDOMAIN};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"LOCALDOMAIN"} 1 7 8
190  
191 8 ▶ $self->nameservers( map {split} $ENV{RES_NAMESERVERS} ) if defined $ENV{RES_NAMESERVERS};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"RES_NAMESERVERS"} 1 7 8
192  
193 8 ▶ $self->searchlist( map {split} $ENV{RES_SEARCHLIST} ) if defined $ENV{RES_SEARCHLIST};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{"RES_SEARCHLIST"} 1 7 8
194  
195 8 ▶ foreach ( map {split} $ENV{RES_OPTIONS} || '' ) {
Condition100%2/2
$ENV{'RES_OPTIONS'} || ''
l!l
17
MC/DC100%1/1
$ENV{'RES_OPTIONS'} || ''
$ENV{'RES_OPTIONS'}
Truth table100%2/2
A
A= $ENV{'RES_OPTIONS'}
Aresult
11
00
196 4 $self->_option( split m/:/ );
197 }
198 8 return;
199 }
200  
201  
202 19 ▶sub _read_config_file { ## read resolver config file
Subroutine _read_config_file: called CC=10 SCAR=23.0
203 19 my ( $self, $file ) = @_;
204  
205 19 ▶ my $filehandle = IO::File->new( $file, '<' ) or croak "$file: $!";
Branch: 1 branch
BranchTrueFalseTotal
my $filehandle = "IO::File"->new($file, "<") or croak("${file}: $!") 17 2 19
206  
207 17 my @nameserver;
208 my @searchlist;
209  
210 17 local $_;
211 17 ▶ while (<$filehandle>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $filehandle)) 90 17 107
212 90 s/[;#].*$//; # strip comments
213  
214 90 ▶ /^nameserver/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^nameserver/ and do { () = grep({defined $_;} split(' ', $_, 0)); push @nameserver, @ip; next } 18 72 90
215 18 my ( $keyword, @ip ) = grep {defined} split;
216 18 push @nameserver, @ip;
217 18 next;
218 };
219  
220 72 ▶ /^domain/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^domain/ and do { () = grep({defined $_;} split(' ', $_, 0)); $self->domain($domain); next } 2 70 72
221 2 my ( $keyword, $domain ) = grep {defined} split;
222 2 $self->domain($domain);
223 2 next;
224 };
225  
226 70 ▶ /^search/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^search/ and do { () = grep({defined $_;} split(' ', $_, 0)); push @searchlist, @domain; next } 10 60 70
227 10 my ( $keyword, @domain ) = grep {defined} split;
228 10 push @searchlist, @domain;
229 10 next;
230 };
231  
232 60 ▶ /^option/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/^option/ and do { () = grep({defined $_;} split(' ', $_, 0)); foreach $_ (@option) { $self->_option(split(/:/, $_, 0)); } } 2 58 60
233 2 my ( $keyword, @option ) = grep {defined} split;
234 2 foreach (@option) {
235 6 $self->_option( split m/:/ );
236 }
237 };
238 }
239  
240 17 close($filehandle);
241  
242 17 ▶ $self->nameservers(@nameserver) if @nameserver;
Branch: 1 branch
BranchTrueFalseTotal
if @nameserver 10 7 17
243 17 ▶ $self->searchlist(@searchlist) if @searchlist;
Branch: 1 branch
BranchTrueFalseTotal
if @searchlist 10 7 17
244 17 return;
245 }
246  
247  
248 2 ▶sub string {
Subroutine string: called CC=2 SCAR=6.9
Pod documented
249 2 my $self = shift;
250 2 ▶ $self = $self->_defaults unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 1 1 2
251  
252 2 my @nslist = $self->nameservers();
253 2 my ($force) = ( grep( { $self->{$_} } qw(force_v6 force_v4) ), 'force_v4' );
254 2 my ($prefer) = ( grep( { $self->{$_} } qw(prefer_v6 prefer_v4) ), 'prefer_v4' );
255 2 return <<END;
256 ;; RESOLVER state:
257 ;; nameservers = @nslist
258 2 ;; searchlist = @{$self->{searchlist}}
259 ;; defnames = $self->{defnames} dnsrch = $self->{dnsrch}
260 ;; igntc = $self->{igntc} usevc = $self->{usevc}
261 ;; recurse = $self->{recurse} port = $self->{port}
262 ;; retrans = $self->{retrans} retry = $self->{retry}
263 ;; tcp_timeout = $self->{tcp_timeout} persistent_tcp = $self->{persistent_tcp}
264 ;; udp_timeout = $self->{udp_timeout} persistent_udp = $self->{persistent_udp}
265 ;; ${prefer} = $self->{$prefer} ${force} = $self->{$force}
266 ;; debug = $self->{debug} ndots = $self->{ndots}
267 END
268 }
269  
270  
271 1 ▶sub print {
Subroutine print: called CC=1 SCAR=0.0
Pod documented
272 1 return print shift->string;
273 }
274  
275  
276 99 ▶sub searchlist {
Subroutine searchlist: called CC=4 SCAR=13.9
Pod documented
277 99 my ( $self, @domain ) = @_;
278 99 ▶ $self = $self->_defaults unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 55 44 99
279  
280 99 foreach (@domain) { $_ = Net::DNS::Domain->new($_)->name }
281 99 ▶ $self->{searchlist} = \@domain if scalar(@domain);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @domain 26 73 99
282 99 return @{$self->{searchlist}};
283 }
284  
285 31 ▶sub domain {
Subroutine domain: called CC=1 SCAR=0.0
Pod documented
286 31 return (&searchlist)[0];
287 }
288  
289  
290 232 ▶sub nameservers {
Subroutine nameservers: called CC=14 SCAR=26.4
Pod documented
291 232 my ( $self, @ns ) = @_;
292 232 ▶ $self = $self->_defaults unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 230 232
293  
294 232 my @ip;
295 232 foreach my $ns ( grep {defined} @ns ) {
296 296 ▶ if ( _ipv4($ns) || _ipv6($ns) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_ipv4($ns) or _ipv6($ns)) { } 289 7 296
Condition100%3/3
_ipv4($ns) or _ipv6($ns)
l!l&&r!l&&!r
1751147
MC/DC100%2/2
_ipv4($ns) or _ipv6($ns)
_ipv4($ns) _ipv6($ns)
Truth table100%3/3
A or B
A= _ipv4($ns)B= _ipv6($ns)
ABresult
1X1
011
000
297 289 push @ip, $ns;
298  
299 } else {
300 7 my $defres = ref($self)->new( debug => $self->{debug} );
301 7 $defres->{persistent} = $self->{persistent};
302  
303 7 my $names = {};
304 7 my $packet = $defres->send( $ns, 'A' );
305 7 my @iplist = _cname_addr( $packet, $names );
306  
307 7 if (IPv6) {
308 7 $packet = $defres->send( $ns, 'AAAA' );
309 7 push @iplist, _cname_addr( $packet, $names );
310 }
311  
312 7 my %unique = map { $_ => $_ } @iplist;
313  
314 7 my @address = values(%unique); # tainted
315 7 ▶ carp "unresolvable name: $ns" unless scalar @address;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @address 1 6 7
316  
317 7 push @ip, @address;
318 }
319 }
320  
321 232 ▶ if ( scalar(@ns) || !defined(wantarray) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @ns or not defined wantarray) 96 136 232
Condition100%3/3
scalar @ns or not defined wantarray
l!l&&r!l&&!r
924136
MC/DC100%2/2
scalar @ns or not defined wantarray
scalar @ns not defined wantarray
Truth table100%3/3
A or not(B)
A= scalar @nsB= not defined wantarray
ABresult
1X1
011
000
322 96 my @ipv4 = grep { _ipv4($_) } @ip;
323 96 my @ipv6 = grep { _ipv6($_) } @ip;
324 96 $self->{nameservers} = \@ip;
325 96 $self->{nameserver4} = \@ipv4;
326 96 $self->{nameserver6} = \@ipv6;
327 }
328  
329 232 my @IPv4 = @{$self->{nameserver4}};
330 232 my @IPv6 = IPv6 ? @{$self->{nameserver6}} : ();
331  
332 232 ▶ my @IPlist = @IPv6 ? @{$self->{nameservers}} : @IPv4;
Branch: 1 branch
BranchTrueFalseTotal
@IPv6 ? : 124 108 232
333 232 ▶ @IPlist = ( @IPv6, @IPv4 ) if $self->{prefer_v6};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prefer_v6"} 5 227 232
334 232 ▶ @IPlist = ( @IPv4, @IPv6 ) if $self->{prefer_v4};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prefer_v4"} 1 231 232
335 232 ▶ @IPlist = @IPv6 if $self->{force_v6};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force_v6"} 3 229 232
336 232 ▶ @IPlist = @IPv4 if $self->{force_v4};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force_v4"} 4 228 232
337  
338 232 ▶ $self->errorstring('no nameservers') unless @IPlist;
Branch: 1 branch
BranchTrueFalseTotal
unless @IPlist 10 222 232
339 232 return @IPlist;
340 }
341  
342 9 ▶sub nameserver { return &nameservers; }
Subroutine nameserver: called CC=1 SCAR=0.0
Pod documented
343  
344 15 ▶sub _cname_addr {
Subroutine _cname_addr: called CC=4 SCAR=13.9
345  
346 # TODO 20081217
347 # This code does not follow CNAME chains, it only looks inside the packet.
348 # Out of bailiwick will fail.
349 15 my @null;
350 15 ▶ my $packet = shift || return @null;
Condition100%2/2
shift() || (return @null)
l!l
123
MC/DC100%1/1
shift() || (return @null)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
351 12 my $names = shift;
352  
353 12 $names->{lc( $_->qname )}++ foreach $packet->question;
354 12 $names->{lc( $_->cname )}++ foreach grep { $_->can('cname') } $packet->answer;
355  
356 12 my @addr = grep { $_->can('address') } $packet->answer;
357 12 return map { $_->address } grep { $names->{lc( $_->name )} } @addr;
358 }
359  
360  
361 2 ▶sub replyfrom {
Subroutine replyfrom: called CC=1 SCAR=0.0
Pod documented
362 2 return shift->{replyfrom};
363 }
364  
365 1 ▶sub answerfrom { return &replyfrom; } # uncoverable pod
Subroutine answerfrom: called CC=1 SCAR=0.0
Pod undocumented (uncoverable)
366  
367  
368 105 ▶sub _reset_errorstring {
Subroutine _reset_errorstring: called CC=1 SCAR=0.0
369 105 shift->{errorstring} = '';
370 105 return;
371 }
372  
373 413 ▶sub errorstring {
Subroutine errorstring: called CC=2 SCAR=6.9
Pod documented
374 413 my ( $self, $text ) = @_;
375 413 ▶ $self->_diag( 'errorstring:', $self->{errorstring} = $text ) if $text;
Branch: 1 branch
BranchTrueFalseTotal
if $text 149 264 413
376 413 return $self->{errorstring};
377 }
378  
379  
380 13 ▶sub query {
Subroutine query: called CC=6 SCAR=17.9
Pod documented
381 13 my ( $self, @argument ) = @_;
382  
383 13 ▶ my $name = shift(@argument) || '.';
Condition100%2/2
shift @argument || '.'
l!l
112
MC/DC100%1/1
shift @argument || '.'
shift @argument
Truth table100%2/2
A
A= shift @argument
Aresult
11
00
384 13 ▶ my @sfix = $self->{defnames} && ( $name !~ m/[.:]/ ) ? $self->domain : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'defnames'} && !($name =~ /[.:]/) ? : 2 11 13
Condition100%3/3
$self->{"defnames"} and not $name =~ /[.:]/
!ll&&!rl&&r
1102
MC/DC100%2/2
$self->{"defnames"} and not $name =~ /[.:]/
$self->{"defnames"} not $name =~ /[.:]/
Truth table100%3/3
A and not(B)
A= $self->{"defnames"}B= not $name =~ /[.:]/
ABresult
0X0
100
111
385  
386 13 my $fqdn = join '.', $name, @sfix;
387 13 $self->_diag( 'query(', $fqdn, @argument, ')' );
388 13 ▶ my $packet = $self->send( $fqdn, @argument ) || return;
Condition100%2/2
$self->send($fqdn, @argument) || (return)
l!l
103
MC/DC100%1/1
$self->send($fqdn, @argument) || (return)
$self->send($fqdn, @argument)
Truth table100%2/2
A
A= $self->send($fqdn, @argument)
Aresult
11
00
389 10 ▶ return $packet->header->ancount ? $packet : undef;
Branch: 1 branch
BranchTrueFalseTotal
$packet->header->ancount ? : 7 3 10
390 }
391  
392  
393 7 ▶sub search {
Subroutine search: called CC=10 SCAR=23.0
Pod documented
394 7 my ( $self, @argument ) = @_;
395  
396 7 ▶ return $self->query(@argument) unless $self->{dnsrch};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"dnsrch"} 1 6 7
397  
398 6 ▶ my $name = shift(@argument) || '.';
Condition100%2/2
shift @argument || '.'
l!l
51
MC/DC100%1/1
shift @argument || '.'
shift @argument
Truth table100%2/2
A
A= shift @argument
Aresult
11
00
399 6 my $dots = $name =~ tr/././;
400  
401 6 ▶ my @sfix = ( $dots < $self->{ndots} ) ? @{$self->{searchlist}} : ();
Branch: 1 branch
BranchTrueFalseTotal
$dots < $self->{'ndots'} ? : 1 5 6
402 6 ▶ my ( $one, @more ) = ( $name =~ m/:|\.\d*$/ ) ? () : ( $dots ? ( undef, @sfix ) : @sfix );
Branch: 2 branches
BranchTrueFalseTotal
$name =~ /:|\.\d*$/ ? : 4 2 6
$dots ? : 1 1 2
403  
404 6 foreach my $suffix ( $one, @more ) {
405 7 ▶ my $fqname = $suffix ? join( '.', $name, $suffix ) : $name;
Branch: 1 branch
BranchTrueFalseTotal
$suffix ? : 2 5 7
406 7 $self->_diag( 'search(', $fqname, @argument, ')' );
407 7 ▶ my $packet = $self->send( $fqname, @argument ) || next;
Condition100%2/2
$self->send($fqname, @argument) || (next)
l!l
25
MC/DC100%1/1
$self->send($fqname, @argument) || (next)
$self->send($fqname, @argument)
Truth table100%2/2
A
A= $self->send($fqname, @argument)
Aresult
11
00
408 2 ▶ return $packet if $packet->header->ancount;
Branch: 1 branch
BranchTrueFalseTotal
if $packet->header->ancount 1 1 2
409 }
410  
411 5 return;
412 }
413  
414  
415 89 ▶sub send {
Subroutine send: called CC=6 SCAR=17.9
Pod documented
416 89 my ( $self, @argument ) = @_;
417 89 my $packet = $self->_make_query_packet(@argument);
418 89 my $packet_data = $packet->encode;
419  
420 89 $self->_reset_errorstring;
421  
422 return $self->_send_tcp( $packet, $packet_data )
423 89 ▶ if $self->{usevc} || length $packet_data > $self->_packetsz;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"usevc"} or length $packet_data > $self->_packetsz 7 82 89
Condition100%3/3
$self->{"usevc"} or length $packet_data > $self->_packetsz
l!l&&r!l&&!r
6182
MC/DC100%2/2
$self->{"usevc"} or length $packet_data > $self->_packetsz
$self->{"usevc"} length $packet_data > $self->_packetsz
Truth table100%3/3
A or B
A= $self->{"usevc"}B= length $packet_data > $self->_packetsz
ABresult
1X1
011
000
424  
425 82 ▶ my $reply = $self->_send_udp( $packet, $packet_data ) || return;
Condition100%2/2
$self->_send_udp($packet, $packet_data) || (return)
l!l
6517
MC/DC100%1/1
$self->_send_udp($packet, $packet_data) || (return)
$self->_send_udp($packet, $packet_data)
Truth table100%2/2
A
A= $self->_send_udp($packet, $packet_data)
Aresult
11
00
426  
427 65 ▶ return $reply if $self->{igntc};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"igntc"} 4 61 65
428 61 ▶ return $reply unless $reply->header->tc;
Branch: 1 branch
BranchTrueFalseTotal
unless $reply->header->tc 60 1 61
429  
430 1 $self->_diag('packet truncated: retrying using TCP');
431 1 return $self->_send_tcp( $packet, $packet_data );
432 }
433  
434  
435 9 ▶sub _send_tcp {
Subroutine _send_tcp: called CC=11 SCAR=24.0
436 9 my ( $self, $query, $query_data ) = @_;
437  
438 9 my $tcp_packet = pack 'n a*', length($query_data), $query_data;
439 9 my @ns = $self->nameservers();
440 9 my $fallback;
441 9 my $timeout = $self->{tcp_timeout};
442  
443 9 foreach my $ip (@ns) {
444 12 $self->_diag( 'tcp send', "[$ip]" );
445  
446 12 my $connection = $self->_create_tcp_socket($ip);
447 12 $self->errorstring($!);
448 12 ▶ my $select = IO::Select->new( $connection || next );
Condition100%2/2
$connection || (next)
l!l
102
MC/DC100%1/1
$connection || (next)
$connection
Truth table100%2/2
A
A= $connection
Aresult
11
00
449  
450 10 $connection->send($tcp_packet);
451 10 $self->errorstring($!);
452  
453 10 my @ready = $select->can_read($timeout);
454 10 ▶ next unless @ready; # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
unless @ready 0 10 10
455 10 my $socket = shift @ready;
456 10 my $buffer = _read_tcp($socket);
457  
458 10 $self->{replyfrom} = $ip;
459 10 $self->_diag( 'packet from', "[$ip]", length($buffer), 'octets' );
460  
461 10 my $reply = Net::DNS::Packet->decode( \$buffer, $self->{debug} );
462 10 $self->errorstring($@);
463 10 ▶ next unless $self->_accept_reply( $reply, $query );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_accept_reply($reply, $query) 2 8 10
464 8 $reply->from( $socket->peerhost );
465  
466 8 ▶ if ( $self->{tsig_rr} && !$reply->verify($query) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tsig_rr"} and not $reply->verify($query)) 2 6 8
Condition100%3/3
$self->{"tsig_rr"} and not $reply->verify($query)
!ll&&!rl&&r
512
MC/DC100%2/2
$self->{"tsig_rr"} and not $reply->verify($query)
$self->{"tsig_rr"} not $reply->verify($query)
Truth table100%3/3
A and not(B)
A= $self->{"tsig_rr"}B= not $reply->verify($query)
ABresult
0X0
100
111
467 2 $self->errorstring( $reply->verifyerr );
468 2 next;
469 }
470  
471 6 my $rcode = $reply->header->rcode;
472 6 ▶ return $reply if $rcode eq 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
if $rcode eq "NOERROR" 3 3 6
473 3 ▶ return $reply if $rcode eq 'NXDOMAIN';
Branch: 1 branch
BranchTrueFalseTotal
if $rcode eq "NXDOMAIN" 1 2 3
474 2 $fallback = $reply;
475 }
476  
477 5 ▶ $self->errorstring( $fallback->header->rcode ) if $fallback;
Branch: 1 branch
BranchTrueFalseTotal
if $fallback 1 4 5
478 5 ▶ $self->errorstring('query timed out') unless $self->errorstring;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->errorstring 2 3 5
479 5 return $fallback;
480 }
481  
482  
483 83 ▶sub _send_udp {
Subroutine _send_udp: called CC=18 SCAR=28.9
484 83 my ( $self, $query, $query_data ) = @_;
485  
486 83 my @ns = $self->nameservers;
487 83 my $port = $self->{port};
488 83 ▶ my $retrans = $self->{retrans} || 1;
Condition100%2/2
$self->{'retrans'} || 1
l!l
7013
MC/DC100%1/1
$self->{'retrans'} || 1
$self->{'retrans'}
Truth table100%2/2
A
A= $self->{'retrans'}
Aresult
11
00
489 83 ▶ my $retry = $self->{retry} || 1;
Condition100%2/2
$self->{'retry'} || 1
l!l
7013
MC/DC100%1/1
$self->{'retry'} || 1
$self->{'retry'}
Truth table100%2/2
A
A= $self->{'retry'}
Aresult
11
00
490 83 my $servers = scalar(@ns);
491 92 ▶ my $timeout = $servers ? do { no integer; $retrans / $servers } : 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$servers ? : 82 1 83
492 83 my $fallback;
493  
494 # Perform each round of retries.
495 83 RETRY: for ( 1 .. $retry ) { # assumed to be a small number
496  
497 # Try each nameserver.
498 98 my $select = IO::Select->new();
499  
500 98 NAMESERVER: foreach my $ns (@ns) {
501  
502 # state vector replaces corresponding element of @ns array
503 177 ▶ unless ( ref $ns ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $ns) 126 51 177
504 126 my $sockaddr = $self->_create_dst_sockaddr( $ns, $port );
505 126 ▶ my $socket = $self->_create_udp_socket($ns) || next;
Condition100%2/2
$self->_create_udp_socket($ns) || (next)
l!l
8739
MC/DC100%1/1
$self->_create_udp_socket($ns) || (next)
$self->_create_udp_socket($ns)
Truth table100%2/2
A
A= $self->_create_udp_socket($ns)
Aresult
11
00
506 87 $ns = [$socket, $ns, $sockaddr];
507 }
508  
509 138 my ( $socket, $ip, $sockaddr, $failed ) = @$ns;
510 138 ▶ next if $failed;
Branch: 1 branch
BranchTrueFalseTotal
if $failed 51 87 138
511  
512 87 $self->_diag( 'udp send', "[$ip]:$port" );
513  
514 87 $select->add($socket);
515 87 $socket->send( $query_data, 0, $sockaddr );
516 87 $self->errorstring( $$ns[3] = $! );
517  
518 87 my $reply;
519 87 ▶ while ( my @ready = $select->can_read($timeout) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@ready) = $select->can_read($timeout)) 70 19 89
520 70 my $socket = shift @ready;
521 70 my $buffer = _read_udp($socket);
522  
523 70 $self->{replyfrom} = $ip;
524 70 $self->_diag( 'packet from', "[$ip]", length($buffer), 'octets' );
525  
526 70 my $packet = Net::DNS::Packet->decode( \$buffer, $self->{debug} );
527 70 $self->errorstring($@);
528 70 ▶ next unless $self->_accept_reply( $packet, $query );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_accept_reply($packet, $query) 2 68 70
529  
530 68 $packet->from( $socket->peerhost );
531 68 $reply = $packet;
532 68 last;
533 } #SELECT LOOP
534  
535 87 ▶ next unless $reply;
Branch: 1 branch
BranchTrueFalseTotal
unless $reply 19 68 87
536  
537 68 ▶ if ( $self->{tsig_rr} && !$reply->verify($query) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tsig_rr"} and not $reply->verify($query)) 2 66 68
Condition100%3/3
$self->{"tsig_rr"} and not $reply->verify($query)
!ll&&!rl&&r
6512
MC/DC100%2/2
$self->{"tsig_rr"} and not $reply->verify($query)
$self->{"tsig_rr"} not $reply->verify($query)
Truth table100%3/3
A and not(B)
A= $self->{"tsig_rr"}B= not $reply->verify($query)
ABresult
0X0
100
111
538 2 $self->errorstring( $$ns[3] = $reply->verifyerr );
539 2 next;
540 }
541  
542 66 my $rcode = $reply->header->rcode;
543 66 ▶ return $reply if $rcode eq 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
if $rcode eq "NOERROR" 61 5 66
544 5 ▶ return $reply if $rcode eq 'NXDOMAIN';
Branch: 1 branch
BranchTrueFalseTotal
if $rcode eq "NXDOMAIN" 3 2 5
545 2 $fallback = $reply;
546 2 $$ns[3] = $rcode;
547 } #NAMESERVER LOOP
548  
549 92 ▶ no integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
550 34 $timeout += $timeout;
551 } #RETRY LOOP
552  
553 19 ▶ $self->errorstring( $fallback->header->rcode ) if $fallback;
Branch: 1 branch
BranchTrueFalseTotal
if $fallback 1 18 19
554 19 ▶ $self->errorstring('query timed out') unless $self->errorstring;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->errorstring 14 5 19
555 19 return $fallback;
556 }
557  
558  
559 16 ▶sub bgsend {
Subroutine bgsend: called CC=3 SCAR=11.0
Pod documented
560 16 my ( $self, @argument ) = @_;
561 16 my $packet = $self->_make_query_packet(@argument);
562 16 my $packet_data = $packet->encode;
563  
564 16 $self->_reset_errorstring;
565  
566 return $self->_bgsend_tcp( $packet, $packet_data )
567 16 ▶ if $self->{usevc} || length $packet_data > $self->_packetsz;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"usevc"} or length $packet_data > $self->_packetsz 7 9 16
Condition100%3/3
$self->{"usevc"} or length $packet_data > $self->_packetsz
l!l&&r!l&&!r
619
MC/DC100%2/2
$self->{"usevc"} or length $packet_data > $self->_packetsz
$self->{"usevc"} length $packet_data > $self->_packetsz
Truth table100%3/3
A or B
A= $self->{"usevc"}B= length $packet_data > $self->_packetsz
ABresult
1X1
011
000
568  
569 9 return $self->_bgsend_udp( $packet, $packet_data );
570 }
571  
572  
573 11 ▶sub _bgsend_tcp {
Subroutine _bgsend_tcp: called CC=3 SCAR=11.0
574 11 my ( $self, $packet, $packet_data ) = @_;
575  
576 11 my $tcp_packet = pack 'n a*', length($packet_data), $packet_data;
577  
578 11 foreach my $ip ( $self->nameservers ) {
579 11 $self->_diag( 'bgsend', "[$ip]" );
580  
581 11 my $socket = $self->_create_tcp_socket($ip);
582 11 $self->errorstring($!);
583 11 ▶ next unless $socket;
Branch: 1 branch
BranchTrueFalseTotal
unless $socket 2 9 11
584  
585 9 $socket->blocking(0);
586 9 $socket->send($tcp_packet);
587 9 $self->errorstring($!);
588 9 $socket->blocking(1);
589  
590 9 my $expire = time() + $self->{tcp_timeout};
591 9 ${*$socket}{net_dns_bg} = [$expire, $packet];
592 9 return $socket;
593 }
594  
595 2 return;
596 }
597  
598  
599 10 ▶sub _bgsend_udp {
Subroutine _bgsend_udp: called CC=3 SCAR=11.0
600 10 my ( $self, $packet, $packet_data ) = @_;
601  
602 10 my $port = $self->{port};
603  
604 10 foreach my $ip ( $self->nameservers ) {
605 11 my $sockaddr = $self->_create_dst_sockaddr( $ip, $port );
606 11 ▶ my $socket = $self->_create_udp_socket($ip) || next;
Condition100%2/2
$self->_create_udp_socket($ip) || (next)
l!l
92
MC/DC100%1/1
$self->_create_udp_socket($ip) || (next)
$self->_create_udp_socket($ip)
Truth table100%2/2
A
A= $self->_create_udp_socket($ip)
Aresult
11
00
607  
608 9 $self->_diag( 'bgsend', "[$ip]:$port" );
609  
610 9 $socket->send( $packet_data, 0, $sockaddr );
611 9 $self->errorstring($!);
612  
613 9 my $expire = time() + $self->{udp_timeout};
614 9 ${*$socket}{net_dns_bg} = [$expire, $packet];
615 9 return $socket;
616 }
617  
618 1 return;
619 }
620  
621  
622 61218 ▶sub bgbusy { ## no critic # overwrites user UDP handle
Subroutine bgbusy: called CC=11 SCAR=24.0
Pod documented
623 61218 my ( $self, $handle ) = @_;
624 61218 ▶ return unless $handle;
Branch: 1 branch
BranchTrueFalseTotal
unless $handle 2 61216 61218
625  
626 61216 ▶ my $appendix = ${*$handle}{net_dns_bg} ||= [time() + $self->{udp_timeout}];
Condition100%2/2
do { *$handle }->{"net_dns_bg"} ||= [time + $self->{"udp_timeout"}]
l!l
612142
MC/DC100%1/1
do { *$handle }->{"net_dns_bg"} ||= [time + $self->{"udp_timeout"}]
do { *$handle }->{"net_dns_bg"}
Truth table100%2/2
A
A= do { *$handle }->{"net_dns_bg"}
Aresult
11
00
627 61216 my ( $expire, $query, $read ) = @$appendix;
628 61216 ▶ return if ref($read);
Branch: 1 branch
BranchTrueFalseTotal
if ref $read 1 61215 61216
629  
630 61215 ▶ return time() < $expire unless IO::Select->new($handle)->can_read(0.02); # limit CPU burn
Branch: 1 branch
BranchTrueFalseTotal
unless "IO::Select"->new($handle)->can_read("0.02") 61201 14 61215
631  
632 14 ▶ return unless $query; # SpamAssassin 3.4.1 workaround
Branch: 1 branch
BranchTrueFalseTotal
unless $query 1 13 14
633 13 ▶ return unless $handle->socktype() == SOCK_DGRAM;
Branch: 1 branch
BranchTrueFalseTotal
unless $handle->socktype == 2 7 6 13
634  
635 6 my $ans = $self->_bgread($handle);
636 6 $$appendix[0] = time();
637 6 $$appendix[2] = [$ans];
638 6 ▶ return unless $ans;
Branch: 1 branch
BranchTrueFalseTotal
unless $ans 1 5 6
639 5 ▶ return if $self->{igntc};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"igntc"} 1 4 5
640 4 ▶ return unless $ans->header->tc;
Branch: 1 branch
BranchTrueFalseTotal
unless $ans->header->tc 2 2 4
641  
642 2 $self->_diag('packet truncated: retrying using TCP');
643 2 ▶ my $tcp = $self->_bgsend_tcp( $query, $query->encode ) || return;
Condition100%2/2
$self->_bgsend_tcp($query, $query->encode) || (return)
l!l
11
MC/DC100%1/1
$self->_bgsend_tcp($query, $query->encode) || (return)
$self->_bgsend_tcp($query, $query->encode)
Truth table100%2/2
A
A= $self->_bgsend_tcp($query, $query->encode)
Aresult
11
00
644 1 return defined( $_[1] = $tcp ); # caller's UDP handle now TCP
645 }
646  
647  
648 1 ▶sub bgisready { ## historical
Subroutine bgisready: called CC=1 SCAR=0.0
Pod undocumented
649 1 __PACKAGE__->_deprecate('prefer ! bgbusy(...)'); # uncoverable pod
650 1 return !&bgbusy;
651 }
652  
653  
654 11 ▶sub bgread {
Subroutine bgread: called CC=2 SCAR=6.9
Pod documented
655 11 ▶ 1 while &bgbusy; ## side effect: TCP retry if TC flag set
Branch: 1 branch
BranchTrueFalseTotal
&bgbusy and do { '???' } 61201 11 61212
656 11 return &_bgread;
657 }
658  
659  
660 18 ▶sub _bgread {
Subroutine _bgread: called CC=8 SCAR=20.8
661 18 my ( $self, $handle ) = @_;
662 18 ▶ return unless $handle;
Branch: 1 branch
BranchTrueFalseTotal
unless $handle 1 17 18
663  
664 17 my $appendix = ${*$handle}{net_dns_bg};
665 17 my ( $expire, $query, $read ) = @$appendix;
666 17 ▶ return shift(@$read) if ref($read);
Branch: 1 branch
BranchTrueFalseTotal
if ref $read 5 12 17
667  
668 12 ▶ return unless IO::Select->new($handle)->can_read(0.2);
Branch: 1 branch
BranchTrueFalseTotal
unless "IO::Select"->new($handle)->can_read("0.2") 1 11 12
669  
670 11 my $dgram = $handle->socktype() == SOCK_DGRAM;
671 11 ▶ my $buffer = $dgram ? _read_udp($handle) : _read_tcp($handle);
Branch: 1 branch
BranchTrueFalseTotal
$dgram ? : 6 5 11
672  
673 11 my $peerhost = $self->{replyfrom} = $handle->peerhost;
674 11 $self->_diag( "packet from [$peerhost]", length($buffer), 'octets' );
675  
676 11 my $reply = Net::DNS::Packet->decode( \$buffer, $self->{debug} );
677 11 $self->errorstring($@);
678  
679 11 ▶ return unless $self->_accept_reply( $reply, $query );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_accept_reply($reply, $query) 1 10 11
680 10 $reply->from($peerhost);
681  
682 10 ▶ return $reply unless $self->{tsig_rr} && !$reply->verify($query);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tsig_rr"} and not $reply->verify($query) 9 1 10
Condition100%3/3
$self->{"tsig_rr"} and not $reply->verify($query)
!ll&&!rl&&r
811
MC/DC100%2/2
$self->{"tsig_rr"} and not $reply->verify($query)
$self->{"tsig_rr"} not $reply->verify($query)
Truth table100%3/3
A and not(B)
A= $self->{"tsig_rr"}B= not $reply->verify($query)
ABresult
0X0
100
111
683 1 $self->errorstring( $reply->verifyerr );
684 1 return;
685 }
686  
687  
688 96 ▶sub _accept_reply {
Subroutine _accept_reply: called CC=5 SCAR=16.1
689 96 my ( $self, $reply, $query ) = @_;
690  
691 96 ▶ return unless $reply;
Branch: 1 branch
BranchTrueFalseTotal
unless $reply 1 95 96
692  
693 95 my $header = $reply->header;
694 95 ▶ return unless $header->qr;
Branch: 1 branch
BranchTrueFalseTotal
unless $header->qr 1 94 95
695  
696 94 ▶ return if $query && ( $header->id != $query->header->id );
Branch: 1 branch
BranchTrueFalseTotal
if $query and $header->id != $query->header->id 6 88 94
Condition100%3/3
$query and $header->id != $query->header->id
!ll&&!rl&&r
1876
MC/DC100%2/2
$query and $header->id != $query->header->id
$query $header->id != $query->header->id
Truth table100%3/3
A and B
A= $queryB= $header->id != $query->header->id
ABresult
0X0
100
111
697  
698 88 return $self->errorstring( $header->rcode ); # historical quirk
699 }
700  
701  
702 9 ▶sub axfr { ## zone transfer
Subroutine axfr: called CC=4 SCAR=13.9
Pod documented
703 9 my ( $self, @argument ) = @_;
704 9 ▶ my $zone = scalar(@argument) ? shift @argument : $self->domain;
Branch: 1 branch
BranchTrueFalseTotal
scalar @argument ? : 7 2 9
705 9 my @class = @argument;
706  
707 9 my $request = $self->_make_query_packet( $zone, 'AXFR', @class );
708  
709 8 return eval {
710 8 $self->_diag("axfr( $zone @class )");
711 8 my ( $select, $verify, @rr, $soa ) = $self->_axfr_start($request);
712  
713 2688 ▶ my $iterator = sub { ## iterate over RRs
Subroutine __ANON__: called CC=6 SCAR=17.9
714 2688 my $rr = shift(@rr);
715  
716 2688 ▶ if ( ref($rr) eq 'Net::DNS::RR::SOA' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rr eq "Net::DNS::RR::SOA") 6 2682 2688
717 6 ▶ if ($soa) {
Branch: 1 branch
BranchTrueFalseTotal
if ($soa) 3 3 6
718 3 $select = undef;
719 3 ▶ return if $rr->canonical eq $soa->canonical;
Branch: 1 branch
BranchTrueFalseTotal
if $rr->canonical eq $soa->canonical 2 1 3
720 1 croak $self->errorstring('mismatched final SOA');
721 }
722 3 $soa = $rr;
723 }
724  
725 2685 ▶ unless ( scalar @rr ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @rr) 28 2657 2685
726 28 my $reply; # refill @rr
727 28 ( $reply, $verify ) = $self->_axfr_next( $select, $verify );
728 28 ▶ @rr = $reply->answer if $reply;
Branch: 1 branch
BranchTrueFalseTotal
if $reply 27 1 28
729 }
730  
731 2685 return $rr;
732 3 };
733  
734 3 ▶ return $iterator unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 1 2 3
735  
736 2 my @zone; ## subvert iterator to assemble entire zone
737 2 ▶ while ( my $rr = $iterator->() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rr = &$iterator()) 20 2 22
738 20 push @zone, $rr, @rr; # copy RRs en bloc
739 20 @rr = pop(@zone); # leave last one in @rr
740 }
741 2 return @zone;
742 };
743 }
744  
745  
746 1 ▶sub axfr_start { ## historical
Subroutine axfr_start: called CC=1 SCAR=0.0
Pod undocumented
747 1 my ( $self, @argument ) = @_; # uncoverable pod
748 1 $self->_deprecate('prefer $iterator = $self->axfr(...)');
749 1 my $iterator = $self->axfr(@argument);
750 1 ▶ ( $self->{axfr_iter} ) = grep {defined} ( $iterator, sub { } );
Subroutine __ANON__: called CC=1 SCAR=0.0
751 1 return defined($iterator);
752 }
753  
754  
755 1 ▶sub axfr_next { ## historical
Subroutine axfr_next: called CC=1 SCAR=0.0
Pod undocumented
756 1 my $self = shift; # uncoverable pod
757 1 $self->_deprecate('prefer $iterator->()');
758 1 return $self->{axfr_iter}->();
759 }
760  
761  
762 8 ▶sub _axfr_start {
Subroutine _axfr_start: called CC=10 SCAR=23.0
763 8 my ( $self, $request ) = @_;
764 8 my $content = $request->encode;
765 8 my $TCP_msg = pack 'n a*', length($content), $content;
766  
767 8 my ( $select, $reply, $rcode );
768 8 foreach my $ns ( $self->nameservers ) {
769 11 $self->_diag("axfr send [$ns]");
770  
771 11 local $self->{persistent_tcp};
772 11 my $socket = $self->_create_tcp_socket($ns);
773 11 $self->errorstring($!);
774 11 ▶ $select = IO::Select->new( $socket || next );
Condition100%2/2
$socket || (next)
l!l
92
MC/DC100%1/1
$socket || (next)
$socket
Truth table100%2/2
A
A= $socket
Aresult
11
00
775  
776 9 $socket->send($TCP_msg);
777 9 $self->errorstring($!);
778  
779 9 ($reply) = $self->_axfr_next($select);
780 9 ▶ last if ( $rcode = $reply->header->rcode ) eq 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
if ($rcode = $reply->header->rcode) eq "NOERROR" 3 6 9
781 }
782  
783 8 ▶ croak $self->errorstring unless $reply;
Branch: 1 branch
BranchTrueFalseTotal
unless $reply 2 6 8
784  
785 6 $self->errorstring($rcode); # historical quirk
786  
787 6 ▶ my $verify = $request->sigrr ? $request : undef;
Branch: 1 branch
BranchTrueFalseTotal
$request->sigrr ? : 3 3 6
788 6 ▶ unless ($verify) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($verify) 3 3 6
789 3 ▶ croak $self->errorstring unless $rcode eq 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
unless $rcode eq "NOERROR" 1 2 3
790 2 return ( $select, $verify, $reply->answer );
791 }
792  
793 3 my $verifyok = $reply->verify($verify);
794 3 ▶ croak $self->errorstring( $reply->verifyerr ) unless $verifyok;
Branch: 1 branch
BranchTrueFalseTotal
unless $verifyok 1 2 3
795 2 ▶ croak $self->errorstring if $rcode ne 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
if $rcode ne "NOERROR" 1 1 2
796 1 return ( $select, $verifyok, $reply->answer );
797 }
798  
799  
800 40 ▶sub _axfr_next {
Subroutine _axfr_next: called CC=6 SCAR=17.9
801 40 my $self = shift;
802 40 ▶ my $select = shift || return;
Condition100%2/2
shift() || (return)
l!l
391
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
803 39 my $verify = shift;
804  
805 39 my ($socket) = $select->can_read( $self->{tcp_timeout} );
806 39 ▶ croak $self->errorstring('timed out') unless $socket;
Branch: 1 branch
BranchTrueFalseTotal
unless $socket 1 38 39
807  
808 38 my $buffer = _read_tcp($socket);
809 38 my $packet = Net::DNS::Packet->decode( \$buffer );
810 38 ▶ croak $@, $self->errorstring('corrupt packet') if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 37 38
811  
812 37 ▶ return ( $packet, $verify ) unless $verify;
Branch: 1 branch
BranchTrueFalseTotal
unless $verify 27 10 37
813  
814 10 my $verifyok = $packet->verify($verify);
815 10 ▶ croak $self->errorstring( $packet->verifyerr ) unless $verifyok;
Branch: 1 branch
BranchTrueFalseTotal
unless $verifyok 1 9 10
816 9 return ( $packet, $verifyok );
817 }
818  
819  
820 #
821 # Usage: $data = _read_tcp($socket);
822 #
823 293 ▶sub _read_socket {
Subroutine _read_socket: called CC=2 SCAR=6.9
824 293 my ( $socket, $size ) = @_;
825 293 my $buffer = '';
826 293 ▶ $socket->recv( $buffer, $size ) if $size;
Branch: 1 branch
BranchTrueFalseTotal
if $size 187 106 293
827 293 return $buffer;
828 }
829  
830 53 ▶sub _read_tcp {
Subroutine _read_tcp: called CC=3 SCAR=11.0
831 53 my $socket = shift;
832  
833 53 my $buffer = '';
834 53 my $header = _read_socket( $socket, 2 );
835 53 $header .= _read_socket( $socket, 2 - length $header );
836 53 ▶ return $buffer if length($header) < 2; # uncoverable branch true
Branch: 1 branch
BranchTrueFalseTotal
if length $header < 2 0 53 53
837 53 my $size = unpack 'n', $header;
838  
839 53 ▶ while ( length( my $fragment = _read_socket( $socket, $size - length $buffer ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(my $fragment = _read_socket($socket, $size - length($buffer)))) 58 53 111
840 58 $buffer .= $fragment;
841 }
842 53 return $buffer;
843 }
844  
845  
846 #
847 # Usage: $data = _read_udp($socket);
848 #
849 76 ▶sub _read_udp {
Subroutine _read_udp: called CC=1 SCAR=0.0
850 76 return _read_socket( shift(), 9000 ); ## payload limit for Ethernet "Jumbo" packet
851 }
852  
853  
854 30 ▶sub _create_tcp_socket {
Subroutine _create_tcp_socket: called CC=5 SCAR=16.1
855 30 my ( $self, $ip, @sockopt ) = @_;
856  
857 30 my $socket;
858 30 my $sock_key = "TCP[$ip]";
859 30 ▶ if ( $socket = $self->{persistent}{$sock_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($socket = $self->{"persistent"}{$sock_key}) 2 28 30
860 2 $self->_diag( 'using persistent socket', $sock_key );
861 2 ▶ return $socket if $socket->connected;
Branch: 1 branch
BranchTrueFalseTotal
if $socket->connected 1 1 2
862 1 $self->_diag('socket disconnected (trying to connect)');
863 }
864  
865 29 my $port = $self->{port};
866 29 Carp::confess 'Insecure dependency while running with -T switch'
867 if TAINT && Scalar::Util::tainted("$ip $port");
868  
869 $socket = IO::Socket::IP->new(
870 LocalAddr => _ipv6($ip) ? $self->{srcaddr6} : $self->{srcaddr4},
871 LocalPort => $self->{srcport},
872 PeerAddr => $ip,
873 PeerPort => $port,
874 Proto => 'tcp',
875 Timeout => $self->{tcp_timeout},
876 29 ▶ GetAddrInfoFlags => AI_NUMERICHOST,
Branch: 1 branch
BranchTrueFalseTotal
_ipv6($ip) ? : 1 28 29
877 @sockopt
878 )
879 if USE_SOCKET_IP;
880  
881 $socket = IO::Socket::INET->new(
882 LocalAddr => $self->{srcaddr4},
883 LocalPort => $self->{srcport} || undef,
884 PeerAddr => $ip,
885 PeerPort => $port,
886 Proto => 'tcp',
887 Timeout => $self->{tcp_timeout},
888 @sockopt
889 29 )
890 unless USE_SOCKET_IP;
891  
892 29 ▶ $self->{persistent}{$sock_key} = $socket if $self->{persistent_tcp};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"persistent_tcp"} 2 27 29
893 29 return $socket;
894 }
895  
896  
897 98 ▶sub _create_udp_socket {
Subroutine _create_udp_socket: called CC=4 SCAR=13.9
898 98 my ( $self, $ip, @sockopt ) = @_;
899  
900 98 my $socket;
901 98 my $sock_key = "UDP[$ip]";
902 98 ▶ return $socket if $socket = $self->{persistent}{$sock_key};
Branch: 1 branch
BranchTrueFalseTotal
if $socket = $self->{"persistent"}{$sock_key} 1 97 98
903  
904 $socket = IO::Socket::IP->new(
905 LocalAddr => _ipv6($ip) ? $self->{srcaddr6} : $self->{srcaddr4},
906 LocalPort => $self->{srcport},
907 97 ▶ Proto => 'udp',
Branch: 1 branch
BranchTrueFalseTotal
_ipv6($ip) ? : 18 79 97
908 Type => SOCK_DGRAM,
909 GetAddrInfoFlags => AI_NUMERICHOST,
910 @sockopt
911 )
912 if USE_SOCKET_IP;
913  
914 97 unless ( USE_SOCKET_IP or _ipv6($ip) ) {
915 $socket = IO::Socket::INET->new(
916 LocalAddr => $self->{srcaddr4},
917 LocalPort => $self->{srcport} || undef,
918 Proto => 'udp',
919 Type => SOCK_DGRAM,
920 @sockopt
921 );
922 }
923  
924 97 ▶ $self->{persistent}{$sock_key} = $socket if $self->{persistent_udp};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"persistent_udp"} 1 96 97
925 97 return $socket;
926 }
927  
928  
929 92 my $ip4 = {
930 family => AF_INET,
931 flags => AI_NUMERICHOST,
932 protocol => IPPROTO_UDP,
933 socktype => SOCK_DGRAM
934 };
935 92 my $ip6 = {
936 family => AF_INET6,
937 flags => AI_NUMERICHOST,
938 protocol => IPPROTO_UDP,
939 socktype => SOCK_DGRAM
940 };
941  
942 137 ▶sub _create_dst_sockaddr { ## create UDP destination sockaddr structure
Subroutine _create_dst_sockaddr: called CC=2 SCAR=6.9
943 137 my ( $self, $ip, $port ) = @_;
944 137 my $addrinfo;
945 137 ▶ ($addrinfo) = grep {ref} Socket::getaddrinfo( $ip, $port, _ipv6($ip) ? $ip6 : $ip4 ), {}
Branch: 1 branch
BranchTrueFalseTotal
_ipv6($ip) ? : 30 107 137
946 if USE_SOCKET_IP;
947 137 $addrinfo = _ipv6($ip) ? undef : sockaddr_in( $port, inet_aton($ip) )
948 unless USE_SOCKET_IP;
949 137 my $sockaddr = USE_SOCKET_IP ? $addrinfo->{addr} : $addrinfo;
950  
951 137 Carp::confess 'Insecure dependency while running with -T switch'
952 if TAINT && Scalar::Util::tainted($sockaddr);
953 137 return $sockaddr;
954 }
955  
956  
957 # Lightweight versions of subroutines from Net::IP module, recoded to fix RT#96812
958  
959 597 ▶sub _ipv4 {
Subroutine _ipv4: called CC=3 SCAR=11.0
960 597 for (shift) {
961 597 ▶ last if m/[^.0-9]/; # dots and digits only
Branch: 1 branch
BranchTrueFalseTotal
if /[^.0-9]/ 241 356 597
962 356 return m/\.\d+\./; # dots separated by digits
963 }
964 241 return;
965 }
966  
967 687 ▶sub _ipv6 {
Subroutine _ipv6: called CC=5 SCAR=16.1
968 687 for (shift) {
969 687 ▶ last unless m/:.*:/; # must contain two colons
Branch: 1 branch
BranchTrueFalseTotal
unless /:.*:/ 403 284 687
970 284 ▶ return 1 unless m/[^:0-9A-Fa-f]/; # colons and hexdigits only
Branch: 1 branch
BranchTrueFalseTotal
unless /[^:0-9A-Fa-f]/ 280 4 284
971 4 ▶ return 1 if m/^[:.0-9A-Fa-f]+\%.+$/; # RFC4007 scoped address
Branch: 1 branch
BranchTrueFalseTotal
if /^[:.0-9A-Fa-f]+\%.+$/ 2 2 4
972 2 return m/^[:0-9A-Fa-f]+:[.0-9]+$/; # prefix : dotted digits
973 }
974 403 return;
975 }
976  
977  
978 133 ▶sub _make_query_packet {
Subroutine _make_query_packet: called CC=4 SCAR=13.9
979 133 my ( $self, @argument ) = @_;
980  
981 133 my ($packet) = @argument;
982 133 ▶ unless ( ref($packet) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $packet) 86 47 133
983 86 $packet = Net::DNS::Packet->new(@argument);
984 85 $packet->edns->udpsize( $self->{udppacketsize} );
985  
986 85 my $header = $packet->header;
987 85 $header->ad( $self->{adflag} ); # RFC6840, 5.7
988 85 $header->cd( $self->{cdflag} ); # RFC6840, 5.9
989 85 $header->do( $self->{dnssec} );
990 85 $header->rd( $self->{recurse} );
991 }
992  
993 132 ▶ if ( $self->{tsig_rr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tsig_rr"}) 12 120 132
994 12 ▶ $packet->sign_tsig( $self->{tsig_rr} ) unless $packet->sigrr;
Branch: 1 branch
BranchTrueFalseTotal
unless $packet->sigrr 11 1 12
995 }
996  
997 132 return $packet;
998 }
999  
1000  
1001 7 ▶sub dnssec {
Subroutine dnssec: called CC=2 SCAR=6.9
Pod documented
1002 7 my ( $self, @argument ) = @_;
1003 7 for (@argument) {
1004 3 $self->udppacketsize(1232);
1005 3 $self->{dnssec} = $_;
1006 }
1007 7 return $self->{dnssec};
1008 }
1009  
1010  
1011 7 ▶sub force_v6 {
Subroutine force_v6: called CC=4 SCAR=13.9
Pod documented
1012 7 my ( $self, @value ) = @_;
1013 7 ▶ for (@value) { $self->{force_v4} = 0 if $self->{force_v6} = $_ }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force_v6"} = $_ 3 1 4
1014 7 ▶ return $self->{force_v6} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'force_v6'} ? : 4 3 7
1015 }
1016  
1017 8 ▶sub force_v4 {
Subroutine force_v4: called CC=4 SCAR=13.9
Pod documented
1018 8 my ( $self, @value ) = @_;
1019 8 ▶ for (@value) { $self->{force_v6} = 0 if $self->{force_v4} = $_ }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force_v4"} = $_ 4 1 5
1020 8 ▶ return $self->{force_v4} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'force_v4'} ? : 5 3 8
1021 }
1022  
1023 8 ▶sub prefer_v6 {
Subroutine prefer_v6: called CC=4 SCAR=13.9
Pod documented
1024 8 my ( $self, @value ) = @_;
1025 8 ▶ for (@value) { $self->{prefer_v4} = 0 if $self->{prefer_v6} = $_ }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prefer_v6"} = $_ 4 1 5
1026 8 ▶ return $self->{prefer_v6} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'prefer_v6'} ? : 5 3 8
1027 }
1028  
1029 6 ▶sub prefer_v4 {
Subroutine prefer_v4: called CC=4 SCAR=13.9
Pod documented
1030 6 my ( $self, @value ) = @_;
1031 6 ▶ for (@value) { $self->{prefer_v6} = 0 if $self->{prefer_v4} = $_ }
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prefer_v4"} = $_ 2 1 3
1032 6 ▶ return $self->{prefer_v4} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'prefer_v4'} ? : 3 3 6
1033 }
1034  
1035 2 ▶sub srcaddr {
Subroutine srcaddr: called CC=3 SCAR=11.0
Pod documented
1036 2 my ( $self, @value ) = @_;
1037 2 for (@value) {
1038 2 ▶ my $hashkey = _ipv6($_) ? 'srcaddr6' : 'srcaddr4';
Branch: 1 branch
BranchTrueFalseTotal
_ipv6($_) ? : 1 1 2
1039 2 $self->{$hashkey} = $_;
1040 }
1041 2 return shift @value;
1042 }
1043  
1044  
1045 9 ▶sub tsig {
Subroutine tsig: called CC=4 SCAR=13.9
Pod documented
1046 9 my ( $self, $arg, @etc ) = @_;
1047 9 ▶ return $arg unless $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless $arg 1 8 9
1048 8 ▶ return $arg if ref($arg) eq 'Net::DNS::RR::TSIG';
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "Net::DNS::RR::TSIG" 1 7 8
1049 7 $self->{tsig_rr} = eval {
1050 7 local $SIG{__DIE__};
1051 7 require Net::DNS::RR::TSIG;
1052 7 Net::DNS::RR::TSIG->create( $arg, @etc );
1053 };
1054 7 ▶ croak "${@}unable to create TSIG record" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 6 7
1055 6 return;
1056 }
1057  
1058  
1059 # if ($self->{udppacketsize} > PACKETSZ
1060 # then we use EDNS and $self->{udppacketsize}
1061 # should be taken as the maximum packet_data length
1062 102 ▶sub _packetsz {
Subroutine _packetsz: called CC=3 SCAR=11.0
1063 102 ▶ my $udpsize = shift->{udppacketsize} || 0;
Condition100%2/2
+(shift())->{'udppacketsize'} || 0
l!l
5547
MC/DC100%1/1
+(shift())->{'udppacketsize'} || 0
+(shift())->{'udppacketsize'}
Truth table100%2/2
A
A= +(shift())->{'udppacketsize'}
Aresult
11
00
1064 102 ▶ return $udpsize > PACKETSZ ? $udpsize : PACKETSZ;
Branch: 1 branch
BranchTrueFalseTotal
$udpsize > 512 ? : 55 47 102
1065 }
1066  
1067 9 ▶sub udppacketsize {
Subroutine udppacketsize: called CC=2 SCAR=6.9
Pod documented
1068 9 my ( $self, @value ) = @_;
1069 9 for (@value) { $self->{udppacketsize} = $_ }
1070 9 return $self->_packetsz;
1071 }
1072  
1073  
1074 #
1075 # Keep this method around. Folk depend on it although it is neither documented nor exported.
1076 #
1077 2 ▶sub make_query_packet { ## historical
Subroutine make_query_packet: called CC=1 SCAR=0.0
Pod undocumented
1078 2 __PACKAGE__->_deprecate('see RT#37104'); # uncoverable pod
1079 2 return &_make_query_packet;
1080 }
1081  
1082  
1083 480 ▶sub _diag { ## debug output
Subroutine _diag: called CC=2 SCAR=6.9
1084 480 ▶ return unless shift->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless +(shift())->{"debug"} 479 1 480
1085 1 return print "\n;; @_\n";
1086 }
1087  
1088  
1089 {
1090 4 ▶ my $parse_dig = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1091 4 require Net::DNS::ZoneFile;
1092  
1093 4 my $dug = Net::DNS::ZoneFile->new( \*DATA );
1094 4 my @rr = $dug->read;
1095  
1096 4 my @auth = grep { $_->type eq 'NS' } @rr;
1097 4 my %auth = map { lc $_->nsdname => 1 } @auth;
1098 4 my %glue;
1099 4 my @glue = grep { $auth{lc $_->name} } @rr;
1100 4 foreach ( grep { $_->can('address') } @glue ) {
1101 104 push @{$glue{lc $_->name}}, $_->address;
1102 }
1103 4 return map {@$_} values %glue;
1104 92 };
1105  
1106 92 my @ip;
1107  
1108 6 ▶ sub _hints { ## default hints
Subroutine _hints: called CC=2 SCAR=6.9
1109 6 ▶ @ip = &$parse_dig unless scalar @ip; # once only, on demand
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @ip 4 2 6
1110 6 splice @ip, 0, 0, splice( @ip, int( rand scalar @ip ) ); # cut deck
1111 6 return @ip;
1112 }
1113 }
1114  
1115  
1116 92 ▶sub DESTROY { } ## Avoid tickling AUTOLOAD (in cleanup)
Subroutine DESTROY: called CC=1 SCAR=0.0
1117  
1118 44 ▶sub AUTOLOAD { ## Default method
Subroutine AUTOLOAD: called CC=2 SCAR=6.9
1119 44 my ($self) = @_;
1120  
1121 92 ▶ no strict 'refs'; ## no critic ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
1122 44 our $AUTOLOAD;
1123 44 my $name = $AUTOLOAD;
1124 44 $name =~ s/.*://;
1125 44 ▶ croak qq[unknown method "$name"] unless $public_attr{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $public_attr{$name} 1 43 44
1126  
1127 43 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1128 100 my $self = shift;
1129 100 ▶ $self = $self->_defaults unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 98 100
1130 100 ▶ $self->{$name} = shift || 0 if scalar @_;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ 76 24 100
Condition100%2/2
shift() || 0
l!l
4432
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1131 100 return $self->{$name};
1132 43 };
1133  
1134 43 return &$AUTOLOAD;
1135 }
1136  
1137  
1138 92 1;
1139  
1140  
1141 =head1 NAME
1142  
1143 Net::DNS::Resolver::Base - DNS resolver base class
1144  
1145 =head1 SYNOPSIS
1146  
1147 use base qw(Net::DNS::Resolver::Base);
1148  
1149 =head1 DESCRIPTION
1150  
1151 This class is the common base class for the different platform
1152 sub-classes of L<Net::DNS::Resolver>.
1153  
1154 No user serviceable parts inside, see L<Net::DNS::Resolver>
1155 for all your resolving needs.
1156  
1157  
1158 =head1 METHODS
1159  
1160 =head2 new, domain, searchlist, nameserver, nameservers,
1161  
1162 =head2 search, query, send, bgsend, bgbusy, bgread, axfr,
1163  
1164 =head2 force_v4, force_v6, prefer_v4, prefer_v6,
1165  
1166 =head2 dnssec, srcaddr, tsig, udppacketsize,
1167  
1168 =head2 print, string, errorstring, replyfrom
1169  
1170 See L<Net::DNS::Resolver>.
1171  
1172  
1173 =head1 COPYRIGHT
1174  
1175 Copyright (c)2003,2004 Chris Reinhardt.
1176  
1177 Portions Copyright (c)2005 Olaf Kolkman.
1178  
1179 Portions Copyright (c)2014-2017 Dick Franks.
1180  
1181 All rights reserved.
1182  
1183  
1184 =head1 LICENSE
1185  
1186 Permission to use, copy, modify, and distribute this software and its
1187 documentation for any purpose and without fee is hereby granted, provided
1188 that the original copyright notices appear in all copies and that both
1189 copyright notice and this permission notice appear in supporting
1190 documentation, and that the name of the author not be used in advertising
1191 or publicity pertaining to distribution of the software without specific
1192 prior written permission.
1193  
1194 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1195 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1196 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1197 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1198 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1199 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1200 DEALINGS IN THE SOFTWARE.
1201  
1202  
1203 =head1 SEE ALSO
1204  
1205 L<perl> L<Net::DNS> L<Net::DNS::Resolver>
1206  
1207 =cut
1208  
1209  
1210 ########################################
1211  
1212 __DATA__ ## DEFAULT HINTS
« DNS/RR/TSIG.pm ↑ Summary DNS/DomainName.pm »