diff --git a/Changes b/Changes index b0518f5c..862b22d4 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,7 @@ * #784 empty device_skip table when also emptying job queue * #788 use device.name instead of device.dns for pseudo devices * #783 fix FQDN discovery in node monitor emails + * #767 also respect dns->no configuration in ip_from_hostname() 2.047005 - 2021-02-24 diff --git a/lib/App/Netdisco/Util/DNS.pm b/lib/App/Netdisco/Util/DNS.pm index 978592b5..1b8e0e6a 100644 --- a/lib/App/Netdisco/Util/DNS.pm +++ b/lib/App/Netdisco/Util/DNS.pm @@ -7,6 +7,8 @@ use Dancer ':script'; use Net::DNS; use NetAddr::IP::Lite ':lower'; +use App::Netdisco::Util::Permission 'check_acl_no'; + use base 'Exporter'; our @EXPORT = (); our @EXPORT_OK = qw/hostname_from_ip ipv4_from_hostname/; @@ -29,6 +31,8 @@ subroutines. Given an IP address (either IPv4 or IPv6), return the canonical hostname. +Will respect the excluded IPs in L configuration. + C<< %opts >> can override the various timeouts available in L: @@ -51,8 +55,11 @@ Returns C if no PTR record exists for the IP. sub hostname_from_ip { my ($ip, $opts) = @_; return unless $ip; + my $skip = setting('dns')->{'no'}; my $ETCHOSTS = setting('dns')->{'ETCHOSTS'}; + return if check_acl_no($ip, $skip); + # check /etc/hosts file and short-circuit if found foreach my $name (reverse sort keys %$ETCHOSTS) { if ($ETCHOSTS->{$name}->[0]->[0] eq $ip) {