| 1 | package Net::DNS::Async::Simple; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::DNS::Async::Simple::VERSION = '1.161060'; | |||||||||||||||||||||||||||
| 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 Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | sub massDNSLookup { | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | my $list = shift | ||||||||||||||||||||||||||
|
Subroutine
massDNSLookup: called CC=5 SCAR=16.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | or die 'Net::DNS::Async::Simple: one argument required'; | ||||||||||||||||||||||||||||
| 10 | 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"
| |||||||||||||||||||||||||||||
| 11 | if not ref $list or ref $list ne 'ARRAY'; | ||||||||||||||||||||||||||||
| 12 | 1 | my $async = new Net::DNS::Async(QueueSize => 20, Retries => 3); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | my $callback = sub { | ||||||||||||||||||||||||||||
| 15 | 2 | ▶ | my ($index, $response) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.9
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | if(not $response) { #timeout | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | $list->[$index]->{timeout} = 1; | |||||||||||||||||||||||||||
| 18 | 0 | return; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | 2 | my @answers = $response->answer; | |||||||||||||||||||||||||||
| 21 | 2 | ▶ | if(not scalar @answers) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | $list->[$index]->{error} = "returned no answers via"; | |||||||||||||||||||||||||||
| 23 | 0 | return; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 2 | foreach my $answer (@answers) { | |||||||||||||||||||||||||||
| 26 | 2 | ▶ | if(ref $answer eq 'Net::DNS::RR::A') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 27 | 1 | $list->[$index]->{name} = $answer->name; | |||||||||||||||||||||||||||
| 28 | 1 | $list->[$index]->{address} = $answer->address; | |||||||||||||||||||||||||||
| 29 | } elsif(ref $answer eq 'Net::DNS::RR::PTR') { | ||||||||||||||||||||||||||||
| 30 | 1 | $list->[$index]->{ptrdname} = $answer->ptrdname; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 1 | }; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | my $i = 0; | |||||||||||||||||||||||||||
| 36 | 1 | ▶ | while($list->[$i]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 2 | my $j = $i; | |||||||||||||||||||||||||||
| 38 | $async->add( | ||||||||||||||||||||||||||||
| 39 | sub { | ||||||||||||||||||||||||||||
| 40 | 2 | ▶ | $callback->($j, @_) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 2 | }, @{$list->[$j]->{query}} | |||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | 2 | $i++; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 1 | $async->await; | |||||||||||||||||||||||||||
| 46 | 1 | return undef; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||