From: Michael Tremer Date: Wed, 14 Aug 2024 16:23:55 +0000 (+0200) Subject: wireguard.cgi: Don't allow creating RW connections if there is no address space X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63a1468e907c6cf8d469df560f04d656c03d0c70;p=people%2Fms%2Fipfire-2.x.git wireguard.cgi: Don't allow creating RW connections if there is no address space Signed-off-by: Michael Tremer --- diff --git a/html/cgi-bin/wireguard.cgi b/html/cgi-bin/wireguard.cgi index 8349fd622..d79f7b896 100644 --- a/html/cgi-bin/wireguard.cgi +++ b/html/cgi-bin/wireguard.cgi @@ -682,19 +682,36 @@ ADD: # Open a new box &Header::openbox('100%', '', $Lang::tr{'connection type'}); + my %disabled = ( + "host" => "", + ); + + # If there is no CLIENT_POOL configured, we disable the option + if ($settings{'CLIENT_POOL'} eq "") { + $disabled{"host"} = "disabled"; + + # If the client pool is out of addresses, we do the same + } else { + my @free_addresses = &free_pool_addresses($settings{'CLIENT_POOL'}, 1); + + if (scalar @free_addresses == 0) { + $disabled{"host"} = "disabled"; + } + } + print <