mirror of
https://github.com/schoebel/mars
synced 2025-01-13 10:24:49 +00:00
marsadm: first try /usr/bin/getent before DNS lookup
This commit is contained in:
parent
8a04c4cbae
commit
421995b3fb
@ -4118,11 +4118,19 @@ sub _get_ip {
|
||||
return $check;
|
||||
}
|
||||
}
|
||||
# Try /usr/bin/host
|
||||
my $answer = `/usr/bin/host -t A $peer`;
|
||||
# Try /usr/bin/getent first
|
||||
my $answer = `/usr/bin/getent hosts '$peer'`;
|
||||
chomp $answer;
|
||||
my $type = "GETENT";
|
||||
if (!$answer || $answer !~ m/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) {
|
||||
# Try /usr/bin/host
|
||||
$answer = `/usr/bin/host -t A '$peer'`;
|
||||
chomp $answer;
|
||||
my $type = "DNS";
|
||||
}
|
||||
if ($answer && $answer =~ m/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) {
|
||||
my $addr = $1;
|
||||
lprint_stderr "DNS query for '$peer' found IPv4 address '$addr'\n";
|
||||
lprint_stderr "$type query for '$peer' found IPv4 address '$addr'\n";
|
||||
$known_ips{$peer} = $addr;
|
||||
return $addr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user