From 63a1468e907c6cf8d469df560f04d656c03d0c70 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 14 Aug 2024 18:23:55 +0200 Subject: [PATCH] wireguard.cgi: Don't allow creating RW connections if there is no address space Signed-off-by: Michael Tremer --- html/cgi-bin/wireguard.cgi | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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 <
  • -- 2.39.5