line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DNS::Async::Simple; |
2
|
|
|
|
|
|
|
$Net::DNS::Async::Simple::VERSION = '1.161060'; |
3
|
1
|
|
|
1
|
|
1056
|
use Modern::Perl; |
|
1
|
|
|
|
|
9069
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
808
|
use Net::DNS::Async; |
|
1
|
|
|
|
|
66280
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
591
|
use Data::Dumper; |
|
1
|
|
|
|
|
4380
|
|
|
1
|
|
|
|
|
415
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub massDNSLookup { |
8
|
1
|
50
|
|
1
|
1
|
358
|
my $list = shift |
9
|
|
|
|
|
|
|
or die 'Net::DNS::Async::Simple: one argument required'; |
10
|
1
|
50
|
33
|
|
|
8
|
die 'Net::DNS::Async::Simple: first required argument must be an ARRAY reference' |
11
|
|
|
|
|
|
|
if not ref $list or ref $list ne 'ARRAY'; |
12
|
1
|
|
|
|
|
9
|
my $async = new Net::DNS::Async(QueueSize => 20, Retries => 3); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $callback = sub { |
15
|
2
|
|
|
2
|
|
6
|
my ($index, $response) = @_; |
16
|
2
|
50
|
|
|
|
11
|
if(not $response) { #timeout |
17
|
0
|
|
|
|
|
0
|
$list->[$index]->{timeout} = 1; |
18
|
0
|
|
|
|
|
0
|
return; |
19
|
|
|
|
|
|
|
} |
20
|
2
|
|
|
|
|
10
|
my @answers = $response->answer; |
21
|
2
|
50
|
|
|
|
23
|
if(not scalar @answers) { |
22
|
0
|
|
|
|
|
0
|
$list->[$index]->{error} = "returned no answers via"; |
23
|
0
|
|
|
|
|
0
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
2
|
|
|
|
|
7
|
foreach my $answer (@answers) { |
26
|
2
|
100
|
|
|
|
12
|
if(ref $answer eq 'Net::DNS::RR::A') { |
|
|
50
|
|
|
|
|
|
27
|
1
|
|
|
|
|
10
|
$list->[$index]->{name} = $answer->name; |
28
|
1
|
|
|
|
|
105
|
$list->[$index]->{address} = $answer->address; |
29
|
|
|
|
|
|
|
} elsif(ref $answer eq 'Net::DNS::RR::PTR') { |
30
|
1
|
|
|
|
|
4
|
$list->[$index]->{ptrdname} = $answer->ptrdname; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
392
|
}; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
2
|
my $i = 0; |
36
|
1
|
|
|
|
|
2
|
while($list->[$i]) { |
37
|
2
|
|
|
|
|
4
|
my $j = $i; |
38
|
|
|
|
|
|
|
$async->add( |
39
|
|
|
|
|
|
|
sub { |
40
|
2
|
|
|
2
|
|
1648599
|
$callback->($j, @_) |
41
|
2
|
|
|
|
|
6
|
}, @{$list->[$j]->{query}} |
|
2
|
|
|
|
|
10
|
|
42
|
|
|
|
|
|
|
); |
43
|
2
|
|
|
|
|
4559
|
$i++; |
44
|
|
|
|
|
|
|
} |
45
|
1
|
|
|
|
|
5
|
$async->await; |
46
|
1
|
|
|
|
|
95
|
return undef; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |