From 3948ba05ec12cddf75a70174baa75097107c407b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 25 Apr 2025 14:06:36 +0200 Subject: [PATCH] wireguard-functions.pl: Fix collecting used IP addresses Signed-off-by: Michael Tremer --- config/cfgroot/wireguard-functions.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index 219f9282d..c8af939b5 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -340,13 +340,14 @@ sub free_pool_addresses($$) { # Collect all used addresses foreach my $key (keys %peers) { - my $type = $peers{$key}[1]; - my $address = $peers{$key}[6]; + my $peer = &load_peer($key); # Only check hosts - next if ($type ne "host"); + next if ($peer->{"TYPE"} ne "host"); - push(@used_addresses, &Network::ip2bin($address)); + foreach my $address (@{ $peer->{"CLIENT_ADDRESS"} }) { + push(@used_addresses, &Network::ip2bin($address)); + } } # Fetch the first address -- 2.39.5