mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-11 08:23:49 +00:00
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:
parent
f4b1eb23ac
commit
57f5105fd0
@ -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 %}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user