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 <fredericojfgomes@gmail.com>
[sunil: Keep the docstring]
[sunil: Adjust markup to eliminate <p> inside <p>]
[sunil: Produce a single <pre> tag instead of multiple for multiple domains]
[sunil: Minor refactoring for more concise code]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Frederico Gomes 2026-01-25 21:10:10 +00:00 committed by Sunil Mohan Adapa
parent f4b1eb23ac
commit 57f5105fd0
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 29 additions and 6 deletions

View File

@ -48,12 +48,24 @@
{% blocktrans trimmed %}
Public key for this {{ box_name }}:
{% endblocktrans %}
{% if server.public_key %}
<pre>{{ server.public_key }}</pre>
{% else %}
<p>{% trans "Not configured yet." %}</p>
{% endif %}
</p>
{% if server.public_key %}
<pre>{{ server.public_key }}</pre>
{% else %}
<p>{% trans "Not configured yet." %}</p>
{% endif %}
<p>
{% blocktrans trimmed %}
Endpoints for this {{ box_name }}:
{% endblocktrans %}
</p>
{% if server_endpoints %}
<pre>{% for endpoint in server_endpoints %}{{ endpoint }}
{% endfor %}</pre>
{% else %}
<p>{% trans "Not configured yet." %}</p>
{% endif %}
<div class="btn-toolbar">
{% if not server.public_key %}

View File

@ -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