line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::DNS::Async::Simple; |
2
|
|
|
|
|
|
|
$Net::DNS::Async::Simple::VERSION = '1.161090'; |
3
|
1
|
|
|
1
|
|
946
|
use Modern::Perl; |
|
1
|
|
|
|
|
8099
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
538
|
use Net::DNS::Async; |
|
1
|
|
|
|
|
59861
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
14
|
use Net::DNS::Resolver; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
6
|
1
|
|
|
1
|
|
4
|
use Storable; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
3
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
454
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub massDNSLookup { |
10
|
1
|
50
|
|
1
|
1
|
342
|
my $list = shift |
11
|
|
|
|
|
|
|
or die 'Net::DNS::Async::Simple: one argument required'; |
12
|
1
|
50
|
33
|
|
|
7
|
die 'Net::DNS::Async::Simple: first required argument must be an ARRAY reference' |
13
|
|
|
|
|
|
|
if not ref $list or ref $list ne 'ARRAY'; |
14
|
1
|
|
|
|
|
2
|
my $asyncs = {}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $callback = sub { |
17
|
2
|
|
|
2
|
|
4
|
my ($index, $response) = @_; |
18
|
2
|
|
|
|
|
4
|
my $item = $list->[$index]; |
19
|
2
|
50
|
|
|
|
7
|
if(not $response) { #timeout |
20
|
0
|
|
|
|
|
0
|
$item->{timeout} = 1; |
21
|
0
|
|
|
|
|
0
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
2
|
|
|
|
|
7
|
my @answers = $response->answer; |
24
|
2
|
50
|
|
|
|
14
|
if(not scalar @answers) { |
25
|
0
|
|
|
|
|
0
|
$item->{error} = "returned no answers via"; |
26
|
0
|
|
|
|
|
0
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
2
|
|
|
|
|
3
|
foreach my $answer (@answers) { |
29
|
2
|
|
|
|
|
5
|
$item->{NetDNSAnswer} = {}; |
30
|
2
|
|
|
|
|
5
|
foreach my $key (keys %$answer) { |
31
|
12
|
|
|
|
|
15
|
my $value = $answer->{$key}; |
32
|
12
|
100
|
|
|
|
14
|
if(ref $value) { |
33
|
3
|
|
|
|
|
174
|
$item->{NetDNSAnswer}->{$key} = Storable::dclone($value); |
34
|
|
|
|
|
|
|
} else { |
35
|
9
|
|
|
|
|
13
|
$item->{NetDNSAnswer}->{$key} = $value; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
2
|
100
|
|
|
|
10
|
if(ref $answer eq 'Net::DNS::RR::A') { |
|
|
50
|
|
|
|
|
|
39
|
1
|
|
|
|
|
8
|
$item->{name} = $answer->name; |
40
|
1
|
|
|
|
|
69
|
$item->{address} = $answer->address; |
41
|
|
|
|
|
|
|
} elsif(ref $answer eq 'Net::DNS::RR::PTR') { |
42
|
1
|
|
|
|
|
3
|
$item->{ptrdname} = $answer->ptrdname; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
1
|
|
|
|
|
4
|
}; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
1
|
my $i = 0; |
48
|
1
|
|
|
|
|
2
|
while($list->[$i]) { |
49
|
2
|
|
|
|
|
5
|
my $item = $list->[$i]; |
50
|
2
|
|
|
|
|
2
|
my $j = $i; |
51
|
2
|
|
|
|
|
2
|
local $Data::Dumper::Sortkeys = 1; |
52
|
2
|
|
100
|
|
|
6
|
my $nameServerInfo = $item->{nameServers} || []; |
53
|
2
|
|
|
|
|
7
|
my $nameServerKey = Data::Dumper::Dumper $nameServerInfo; |
54
|
2
|
50
|
|
|
|
123
|
if(not $asyncs->{$nameServerKey}) { |
55
|
2
|
|
|
|
|
7
|
$asyncs->{$nameServerKey} = Net::DNS::Async->new(QueueSize => 20, Retries => 3); |
56
|
2
|
100
|
|
|
|
319
|
if($item->{nameServers}) { |
57
|
|
|
|
|
|
|
$asyncs->{$nameServerKey}->{Resolver} = Net::DNS::Resolver->new( |
58
|
|
|
|
|
|
|
nameservers => $item->{nameServers} |
59
|
1
|
|
|
|
|
3
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
2
|
50
|
33
|
|
|
69
|
if($list->[$j]->{query}->[0] and $list->[$j]->{query}->[1]) { |
63
|
|
|
|
|
|
|
$asyncs->{$nameServerKey}->add( |
64
|
|
|
|
|
|
|
sub { |
65
|
2
|
|
|
2
|
|
1357822
|
$callback->($j, @_) |
66
|
2
|
|
|
|
|
7
|
}, @{$list->[$j]->{query}} |
|
2
|
|
|
|
|
6
|
|
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
2
|
|
|
|
|
4048
|
$i++; |
70
|
|
|
|
|
|
|
} |
71
|
1
|
|
|
|
|
1
|
foreach my $nameServerKey (keys %{$asyncs}) { |
|
1
|
|
|
|
|
3
|
|
72
|
2
|
|
|
|
|
51
|
$asyncs->{$nameServerKey}->await; |
73
|
|
|
|
|
|
|
} |
74
|
1
|
|
|
|
|
97
|
return undef; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |