| 1 | package Net::DNS::Async::Simple; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::DNS::Async::Simple::VERSION = '1.161090'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Modern::Perl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Net::DNS::Async; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Net::DNS::Resolver; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | sub massDNSLookup { | ||||||||||||||||||||||||||
|
Subroutine
massDNSLookup: called CC=11 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | my $list = shift | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | or die 'Net::DNS::Async::Simple: one argument required'; | ||||||||||||||||||||||||||||
| 12 | 1 | ▶ | die 'Net::DNS::Async::Simple: first required argument must be an ARRAY reference' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $list or ref $list ne "ARRAY"
MC/DC0%0/2
not ref $list or ref $list ne "ARRAY"
not ref $list
ref $list ne "ARRAY"
Truth table33%1/3
not(A) or B
A= not ref $listB= ref $list ne "ARRAY"
| |||||||||||||||||||||||||||||
| 13 | if not ref $list or ref $list ne 'ARRAY'; | ||||||||||||||||||||||||||||
| 14 | 1 | my $asyncs = {}; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | my $callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.8
| |||||||||||||||||||||||||||||
| 17 | 2 | my ($index, $response) = @_; | |||||||||||||||||||||||||||
| 18 | 2 | my $item = $list->[$index]; | |||||||||||||||||||||||||||
| 19 | 2 | ▶ | if(not $response) { #timeout | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | $item->{timeout} = 1; | |||||||||||||||||||||||||||
| 21 | 0 | return; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 2 | my @answers = $response->answer; | |||||||||||||||||||||||||||
| 24 | 2 | ▶ | if(not scalar @answers) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | $item->{error} = "returned no answers via"; | |||||||||||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 2 | foreach my $answer (@answers) { | |||||||||||||||||||||||||||
| 29 | 2 | $item->{NetDNSAnswer} = {}; | |||||||||||||||||||||||||||
| 30 | 2 | foreach my $key (keys %$answer) { | |||||||||||||||||||||||||||
| 31 | 12 | my $value = $answer->{$key}; | |||||||||||||||||||||||||||
| 32 | 12 | ▶ | if(ref $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 3 | $item->{NetDNSAnswer}->{$key} = Storable::dclone($value); | |||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||
| 35 | 9 | $item->{NetDNSAnswer}->{$key} = $value; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 2 | ▶ | if(ref $answer eq 'Net::DNS::RR::A') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 39 | 1 | $item->{name} = $answer->name; | |||||||||||||||||||||||||||
| 40 | 1 | $item->{address} = $answer->address; | |||||||||||||||||||||||||||
| 41 | } elsif(ref $answer eq 'Net::DNS::RR::PTR') { | ||||||||||||||||||||||||||||
| 42 | 1 | $item->{ptrdname} = $answer->ptrdname; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 1 | }; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | my $i = 0; | |||||||||||||||||||||||||||
| 48 | 1 | ▶ | while($list->[$i]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 2 | my $item = $list->[$i]; | |||||||||||||||||||||||||||
| 50 | 2 | my $j = $i; | |||||||||||||||||||||||||||
| 51 | 2 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||
| 52 | 2 | ▶ | my $nameServerInfo = $item->{nameServers} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$item->{'nameServers'} || []
MC/DC100%1/1
$item->{'nameServers'} || []
$item->{'nameServers'}
Truth table100%2/2
A
A= $item->{'nameServers'}
| |||||||||||||||||||||||||||||
| 53 | 2 | my $nameServerKey = Data::Dumper::Dumper $nameServerInfo; | |||||||||||||||||||||||||||
| 54 | 2 | ▶ | if(not $asyncs->{$nameServerKey}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 2 | $asyncs->{$nameServerKey} = Net::DNS::Async->new(QueueSize => 20, Retries => 3); | |||||||||||||||||||||||||||
| 56 | 2 | ▶ | if($item->{nameServers}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | $asyncs->{$nameServerKey}->{Resolver} = Net::DNS::Resolver->new( | ||||||||||||||||||||||||||||
| 58 | nameservers => $item->{nameServers} | ||||||||||||||||||||||||||||
| 59 | 1 | ); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 2 | ▶ | if($list->[$j]->{query}->[0] and $list->[$j]->{query}->[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$list->[$j]{"query"}[0] and $list->[$j]{"query"}[1]
MC/DC0%0/2
$list->[$j]{"query"}[0] and $list->[$j]{"query"}[1]
$list->[$j]{"query"}[0]
$list->[$j]{"query"}[1]
Truth table33%1/3
A and B
A= $list->[$j]{"query"}[0]B= $list->[$j]{"query"}[1]
| |||||||||||||||||||||||||||||
| 63 | $asyncs->{$nameServerKey}->add( | ||||||||||||||||||||||||||||
| 64 | 2 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 2 | $callback->($j, @_) | |||||||||||||||||||||||||||
| 66 | 2 | }, @{$list->[$j]->{query}} | |||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 2 | $i++; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 1 | foreach my $nameServerKey (keys %{$asyncs}) { | |||||||||||||||||||||||||||
| 72 | 2 | $asyncs->{$nameServerKey}->await; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 1 | return undef; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||