| 1 | # You may distribute under the terms of either the GNU General Public License | ||||||||||||||||||||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # (C) Paul Evans, 2011-2013 -- leonerd@leonerd.org.uk | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | package IO::Async::Resolver::DNS::NetDNSImpl; | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | our $VERSION = '0.04'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | ▶ | use Net::DNS::Resolver; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 3 | my $res; | |||||||||||||||||||
| 16 | sub _resolve | ||||||||||||||||||||
| 17 | { | ||||||||||||||||||||
| 18 | 2 | ▶ | my ( $method, $dname, $class, $type ) = @_; | ||||||||||||||||||
|
Subroutine
_resolve: called CC=4 SCAR=16.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | ▶ | $res ||= Net::DNS::Resolver->new; | ||||||||||||||||||
|
Condition66%2/3
$res ||= "Net::DNS::Resolver"->new
MC/DC0%0/2
$res ||= "Net::DNS::Resolver"->new
$res
"Net::DNS::Resolver"->new
Truth table66%2/3
A ||= B
A= $resB= "Net::DNS::Resolver"->new
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 2 | my $pkt = $res->$method( $dname, $type, $class ); # !order | |||||||||||||||||||
| 23 | 2 | ▶ | if( !$pkt ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | my $errorstring = $res->errorstring; | |||||||||||||||||||
| 25 | # Net::DNS::Resolver yields NOERROR for successful DNS queries that just | ||||||||||||||||||||
| 26 | # didn't yield any records of the type we wanted. Rewrite that into | ||||||||||||||||||||
| 27 | # NODATA instead | ||||||||||||||||||||
| 28 | 0 | ▶ | die "NODATA\n" if $errorstring eq "NOERROR"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 0 | die "$errorstring\n"; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # placate Net::DNS::Packet bug | ||||||||||||||||||||
| 33 | 2 | $pkt->answer; $pkt->authority; $pkt->additional; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 2 | return $pkt->data; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 1 | ▶ | sub IO::Async::Resolver::DNS::res_query { _resolve( query => @_ ) } | ||||||||||||||||||
|
Subroutine
res_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 40 | 1 | ▶ | sub IO::Async::Resolver::DNS::res_search { _resolve( search => @_ ) } | ||||||||||||||||||
|
Subroutine
res_search: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 3 | 0x55AA; | |||||||||||||||||||