5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-03-08 08:58:43 +03:00

network: cleanup get_local_ip_from_cidr

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-11-08 12:47:16 +01:00
parent 484b6b398b
commit b15e50dda1

View File

@ -585,19 +585,12 @@ sub is_ip_in_cidr {
sub get_local_ip_from_cidr {
my ($cidr) = @_;
my $cmd = ['/sbin/ip', 'address', 'show', 'to', $cidr, 'up'];
my $IPs = [];
my $code = sub {
my $line = shift;
if ($line =~ m!^\s*inet(?:6)?\s+($PVE::Tools::IPRE)(?:/\d+|\s+peer\s+)!) {
run_command(['/sbin/ip', 'address', 'show', 'to', $cidr, 'up'], outfunc => sub {
if ($_[0] =~ m!^\s*inet(?:6)?\s+($PVE::Tools::IPRE)(?:/\d+|\s+peer\s+)!) {
push @$IPs, $1;
}
};
PVE::Tools::run_command($cmd, outfunc => $code);
});
return $IPs;
}