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