mirror of
git://git.proxmox.com/git/pve-common.git
synced 2025-03-09 12:58:35 +03:00
network: cleanup get_local_ip_from_cidr
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
484b6b398b
commit
b15e50dda1
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user