[#59] Arpnip tries to resolve link local IPv6 addresses
This commit is contained in:
@@ -761,12 +761,18 @@ Value: Settings Tree. Default:
|
||||
|
||||
dns:
|
||||
max_outstanding: 250
|
||||
no: ['fe80::/64','169.254.0.0/16']
|
||||
|
||||
Sets the maximum number of outstanding requests for asynchronous DNS
|
||||
resolution used during arpnip and device alias discovery.
|
||||
Controls the asynchronous DNS resolver used to resolve IP addresses to
|
||||
names during arpnip and discovery of device aliases.
|
||||
|
||||
This setting overrides the C<PERL_ANYEVENT_MAX_OUTSTANDING_DNS> environment
|
||||
value and the C<AnyEvent> library default of 10.
|
||||
C<max_outstanding> sets the maximum number of outstanding requests for
|
||||
asynchronous DNS resolution. This setting overrides the
|
||||
C<PERL_ANYEVENT_MAX_OUTSTANDING_DNS> environment value and the C<AnyEvent>
|
||||
library default of 10.
|
||||
|
||||
C<no> is a list of IP addresses or CIDR ranges to excluded from DNS
|
||||
resolution. Link local addresses are excluded by default.
|
||||
|
||||
=head3 C<housekeeping>
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@ package App::Netdisco::Util::DNS;
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
|
||||
use Dancer ':script';
|
||||
use Net::DNS;
|
||||
use AnyEvent::DNS::EtcHosts;
|
||||
use AnyEvent::DNS;
|
||||
use NetAddr::IP::Lite ':lower';
|
||||
|
||||
use base 'Exporter';
|
||||
our @EXPORT = ();
|
||||
@@ -104,6 +106,7 @@ sub hostnames_resolve_async {
|
||||
|
||||
foreach my $hash_ref (@$ips) {
|
||||
my $ip = $hash_ref->{'ip'} || $hash_ref->{'alias'};
|
||||
next if no_resolve($ip);
|
||||
$done->begin;
|
||||
AnyEvent::DNS::reverse_verify $ip,
|
||||
sub { $hash_ref->{'dns'} = shift; $done->end; };
|
||||
@@ -118,5 +121,30 @@ sub hostnames_resolve_async {
|
||||
return $ips;
|
||||
}
|
||||
|
||||
=head2 no_resolve( $ip )
|
||||
|
||||
Given an IP address, returns true if excluded from DNS resolution by the
|
||||
C<dns_no> configuration directive, otherwise returns false.
|
||||
|
||||
=cut
|
||||
|
||||
sub no_resolve {
|
||||
my $ip = shift;
|
||||
|
||||
my $config = setting('dns')->{no} || [];
|
||||
return 0 if not scalar @$config;
|
||||
|
||||
my $addr = NetAddr::IP::Lite->new($ip);
|
||||
|
||||
foreach my $item (@$config) {
|
||||
my $c_ip = NetAddr::IP::Lite->new($item)
|
||||
or next;
|
||||
next unless $c_ip->bits == $addr->bits;
|
||||
|
||||
return 1 if ($c_ip->contains($addr));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user