mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
wireguard: Show this box's public key
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
87a58f1491
commit
aed82eca1b
@ -104,6 +104,19 @@ def setup(helper, old_version=None):
|
|||||||
helper.call('post', app.enable)
|
helper.call('post', app.enable)
|
||||||
|
|
||||||
|
|
||||||
|
def get_public_key():
|
||||||
|
"""Return this box's public key."""
|
||||||
|
public_key_path = '/var/lib/freedombox/wireguard/publickey'
|
||||||
|
try:
|
||||||
|
with open(public_key_path) as public_key_file:
|
||||||
|
public_key = public_key_file.read().strip()
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
public_key = None
|
||||||
|
|
||||||
|
return public_key
|
||||||
|
|
||||||
|
|
||||||
def get_info():
|
def get_info():
|
||||||
"""Return server and clients info."""
|
"""Return server and clients info."""
|
||||||
output = actions.superuser_run('wireguard', ['get-info'])
|
output = actions.superuser_run('wireguard', ['get-info'])
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
<h3>{% trans "Server" %}</h3>
|
<h3>{% trans "Server" %}</h3>
|
||||||
|
|
||||||
<p>{% trans "Peers allowed to connect to this server" %}</p>
|
<p>{% trans "Peers allowed to connect to this server" %}</p>
|
||||||
|
|
||||||
<table class="table table-bordered table-condensed table-striped"
|
<table class="table table-bordered table-condensed table-striped"
|
||||||
id="server-peers-list">
|
id="server-peers-list">
|
||||||
<tr>
|
<tr>
|
||||||
@ -109,6 +110,16 @@
|
|||||||
{% trans "Add Server" %}
|
{% trans "Add Server" %}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<h3>{% trans "Connection Information" %}</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% blocktrans %}
|
||||||
|
Public key for this {{ box_name }}:
|
||||||
|
{% endblocktrans %}
|
||||||
|
|
||||||
|
<pre>{{ public_key }}</pre>
|
||||||
|
</p>
|
||||||
|
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class WireguardView(AppView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Return additional context for rendering the template."""
|
"""Return additional context for rendering the template."""
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['public_key'] = wireguard.get_public_key()
|
||||||
info = wireguard.get_info()
|
info = wireguard.get_info()
|
||||||
context['server_peers'] = info['my_server']['clients']
|
context['server_peers'] = info['my_server']['clients']
|
||||||
context['client_peers'] = info['my_client']['servers']
|
context['client_peers'] = info['my_client']['servers']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user