DNS/LibResolvImpl.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« DNS.pm ↑ Summary DNS/Constants.pm »
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-2015 -- leonerd@leonerd.org.uk
5  
6 package IO::Async::Resolver::DNS::LibResolvImpl;
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 our $VERSION = '0.06';
12  
13 0 ▶use Net::LibResolv 0.03 qw( res_query res_search class_name2value type_name2value $h_errno );
Subroutine BEGIN: called CC=1 SCAR=2.6
14  
15 use IO::Async::Resolver;
16 use constant HAVE_IO_ASYNC_RESOLVER_EXTENDED_ERROR => ( $IO::Async::Resolver::VERSION >= '0.68' );
17  
18 use IO::Async::Resolver::DNS::Constants qw( /^ERR_/ );
19  
20 my %errmap = (
21 Net::LibResolv::HOST_NOT_FOUND => ERR_NO_HOST,
22 Net::LibResolv::NO_ADDRESS => ERR_NO_ADDRESS,
23 Net::LibResolv::NO_DATA => ERR_NO_ADDRESS,
24 Net::LibResolv::NO_RECOVERY => ERR_UNRECOVERABLE,
25 Net::LibResolv::TRY_AGAIN => ERR_TEMPORARY,
26 );
27  
28 sub _resolve
29 {
30 my ( $func, $dname, $class, $type ) = @_;
31 my $pkt = $func->( $dname, class_name2value($class), type_name2value($type) );
32 if( !defined $pkt ) {
33 # We can't easily detect NODATA errors here, so we'll have to let the
34 # higher-level function do it
35 die HAVE_IO_ASYNC_RESOLVER_EXTENDED_ERROR
36 ? [ "$h_errno", $errmap{$h_errno+0} ]
37 : "$h_errno\n";
38 }
39  
40 return $pkt;
41 }
42  
43 sub IO::Async::Resolver::DNS::res_query { _resolve( \&res_query, @_ ) }
44 sub IO::Async::Resolver::DNS::res_search { _resolve( \&res_search, @_ ) }
45  
46 0x55AA;
« DNS.pm ↑ Summary DNS/Constants.pm »