]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
wireguard-functions.pl: Fix collecting used IP addresses
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Apr 2025 12:06:36 +0000 (14:06 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Apr 2025 12:06:36 +0000 (14:06 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/wireguard-functions.pl

index 219f9282d3bb88269d597dad0def53f68cef6116..c8af939b58bc106f6b820c74e2073df9d652d5a2 100644 (file)
@@ -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