From b0a841c63ae86c50fa309b6396c8dd82f07fcefc Mon Sep 17 00:00:00 2001 From: Frederico Gomes Date: Mon, 26 Jan 2026 12:39:19 +0000 Subject: [PATCH] wireguard: Show next available client IP in Add Client form Display the next available IP address that will be automatically assigned when adding a new client. Helps admins know what client IP to provide when configuring client connections back to this server. Signed-off-by: Frederico Gomes [sunil: Turn the IP address styling into a form element] [sunil: Update the comment style for consistency] [sunil: Update the label for clarity] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- .../wireguard/templates/wireguard_add_client.html | 12 ++++++++++++ plinth/modules/wireguard/views.py | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/plinth/modules/wireguard/templates/wireguard_add_client.html b/plinth/modules/wireguard/templates/wireguard_add_client.html index 466f2d011..909066ddd 100644 --- a/plinth/modules/wireguard/templates/wireguard_add_client.html +++ b/plinth/modules/wireguard/templates/wireguard_add_client.html @@ -15,6 +15,18 @@ {{ form|bootstrap }} + {% if next_ip %} +
+ +
+ +
+
+ {% endif %} + diff --git a/plinth/modules/wireguard/views.py b/plinth/modules/wireguard/views.py index 48fcc45f8..5de984006 100644 --- a/plinth/modules/wireguard/views.py +++ b/plinth/modules/wireguard/views.py @@ -46,6 +46,16 @@ class AddClientView(SuccessMessageMixin, FormView): """Return additional context for rendering the template.""" context = super().get_context_data(**kwargs) context['title'] = _('Add Allowed Client') + + # Show next available IP. + try: + connection = utils._server_connection() + setting_name = utils.nm.SETTING_WIREGUARD_SETTING_NAME + settings = connection.get_setting_by_name(setting_name) + context['next_ip'] = utils._get_next_available_ip_address(settings) + except Exception: + context['next_ip'] = None + return context def form_valid(self, form):