mirror of
git://git.proxmox.com/git/pve-common.git
synced 2025-01-08 01:17:37 +03:00
net: ip from host: code shrink
Return a suitable address directly instead of breaking out of the loop to do that. no semantic change intended Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
c45692e04a
commit
29dde5f46b
@ -632,21 +632,15 @@ sub get_ip_from_hostname {
|
||||
return undef;
|
||||
}
|
||||
|
||||
my ($ip, $family);
|
||||
for my $ai (@res) {
|
||||
$family = $ai->{family};
|
||||
my $tmpip = addr_to_ip($ai->{addr});
|
||||
if ($tmpip !~ m/^127\.|^::1$/) {
|
||||
$ip = $tmpip;
|
||||
last;
|
||||
my $ip = addr_to_ip($ai->{addr});
|
||||
if ($ip !~ m/^127\.|^::1$/) {
|
||||
return wantarray ? ($ip, $ai->{family}) : $ip;
|
||||
}
|
||||
}
|
||||
if (!defined($ip) ) {
|
||||
die "address lookup for '$hostname' did not find any IP address\n" if !$noerr;
|
||||
return undef;
|
||||
}
|
||||
|
||||
return wantarray ? ($ip, $family) : $ip;
|
||||
# NOTE: we only get here if no WAN/LAN IP was found, so this is now the error path!
|
||||
die "address lookup for '$hostname' did not find any IP address\n" if !$noerr;
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub lock_network {
|
||||
|
Loading…
Reference in New Issue
Block a user