From 57f5105fd0cec420ec56cedc0d87c91b16740251 Mon Sep 17 00:00:00 2001 From: Frederico Gomes Date: Sun, 25 Jan 2026 21:10:10 +0000 Subject: [PATCH] wireguard: show server endpoint on main app page Display the WireGuard server endpoint (ip_address:listen_port) alongside the public key on the main WireGuard page, so users configuring clients can copy both values directly. Signed-off-by: Frederico Gomes [sunil: Keep the docstring] [sunil: Adjust markup to eliminate

inside

] [sunil: Produce a single

 tag instead of multiple for multiple domains]
[sunil: Minor refactoring for more concise code]
Signed-off-by: Sunil Mohan Adapa 
Reviewed-by: Sunil Mohan Adapa 
---
 .../wireguard/templates/wireguard.html        | 22 ++++++++++++++-----
 plinth/modules/wireguard/views.py             | 13 ++++++++++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/plinth/modules/wireguard/templates/wireguard.html b/plinth/modules/wireguard/templates/wireguard.html
index af7551b26..f4cee1728 100644
--- a/plinth/modules/wireguard/templates/wireguard.html
+++ b/plinth/modules/wireguard/templates/wireguard.html
@@ -48,12 +48,24 @@
     {% blocktrans trimmed %}
       Public key for this {{ box_name }}:
     {% endblocktrans %}
-    {% if server.public_key %}
-      
{{ server.public_key }}
- {% else %} -

{% trans "Not configured yet." %}

- {% endif %}

+ {% if server.public_key %} +
{{ server.public_key }}
+ {% else %} +

{% trans "Not configured yet." %}

+ {% endif %} + +

+ {% blocktrans trimmed %} + Endpoints for this {{ box_name }}: + {% endblocktrans %} +

+ {% if server_endpoints %} +
{% for endpoint in server_endpoints %}{{ endpoint }}
+{% endfor %}
+ {% else %} +

{% trans "Not configured yet." %}

+ {% endif %}
{% if not server.public_key %} diff --git a/plinth/modules/wireguard/views.py b/plinth/modules/wireguard/views.py index 5de984006..4b20458dd 100644 --- a/plinth/modules/wireguard/views.py +++ b/plinth/modules/wireguard/views.py @@ -30,8 +30,19 @@ class WireguardView(AppView): """Return additional context for rendering the template.""" context = super().get_context_data(**kwargs) info = utils.get_info() - context['server'] = info['my_server'] + server_info = info['my_server'] + context['server'] = server_info context['client_peers'] = info['my_client']['servers'] + context['server_endpoints'] = [] + + if server_info: + domains = DomainName.list_names(filter_for_service='wireguard') + listen_port = server_info.get('listen_port') + context['server_endpoints'] = [ + f'{domain}:{listen_port}' for domain in domains + if not domain.endswith('.local') + ] + return context