mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-07 13:59:11 +00: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 {
|
sub get_local_ip_from_cidr {
|
||||||
my ($cidr) = @_;
|
my ($cidr) = @_;
|
||||||
|
|
||||||
my $cmd = ['/sbin/ip', 'address', 'show', 'to', $cidr, 'up'];
|
|
||||||
|
|
||||||
my $IPs = [];
|
my $IPs = [];
|
||||||
|
run_command(['/sbin/ip', 'address', 'show', 'to', $cidr, 'up'], outfunc => sub {
|
||||||
my $code = sub {
|
if ($_[0] =~ m!^\s*inet(?:6)?\s+($PVE::Tools::IPRE)(?:/\d+|\s+peer\s+)!) {
|
||||||
my $line = shift;
|
|
||||||
|
|
||||||
if ($line =~ m!^\s*inet(?:6)?\s+($PVE::Tools::IPRE)(?:/\d+|\s+peer\s+)!) {
|
|
||||||
push @$IPs, $1;
|
push @$IPs, $1;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
PVE::Tools::run_command($cmd, outfunc => $code);
|
|
||||||
|
|
||||||
return $IPs;
|
return $IPs;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user