FreedomBox/plinth/modules/wireguard/templates/wireguard_show_server.html
Sunil Mohan Adapa 4b24fda3f5
wireguard: Accept/use netmask with IP address for server connection
- Currently, the value is hard-coded as /24. Instead take this as input and use
that value.

Tests:

- Entering invalid IPv4 address results in 'Enter a valid IPv4 address' error
message during form submission.

- Entering invalid prefix such as /33 results in 'Enter a valid network prefix
or net mask.' error during form submission.

- Both /32 and /255.255.255.255 formats are accepted.

- The description text for the form field 'IP address' is as expected.

- Changing the value of default route and IP address + netmask reflects in the
status page. Correct values is shown in the edit server and server status page.

- Not providing a netmask results in /32 being assigned.

- Unit and functional tests for wireguard pass. There are some intermittent
failures with functional tests that are unrelated to the patch.

- Setting the /32 prefix results in correct routing table as shown by 'ip route
show table all'. No default routes are network routes are present. 'traceroute
1.1.1.1' shows route taken via regular network.

- Setting the /24 prefix results in correct routing table. No default routes are
present. However, for the /24 network a route is present with device wg1.
'traceroute 1.1.1.1' shows route taken via regular network.

- Enabling the default route results in correct routing table. Default route is
shown for device wg1 with high priority. 'traceroute 1.1.1.1' shows route taken
via WireGuard network.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2026-03-02 15:22:36 -05:00

94 lines
3.0 KiB
HTML

{% extends "base.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block content %}
{% for peer in server.peers.values %}
{% if forloop.first %}
<h3>{{ title }}</h3>
<p>
{% blocktrans trimmed %}
{{ box_name }} will attempt to reach a WireGuard server with the
following information. Ensure that the server is configured to allow
{{ box_name }}'s public key and IP address.
{% endblocktrans %}
</p>
<div class="table-responsive">
<table class="table">
<tbody>
<tr class="peer-endpoint">
<th>{% trans "Server endpoint:" %}</th>
<td>{{ peer.endpoint }}</td>
</tr>
<tr class="peer-public-key">
<th>{% trans "Server public key:" %}</th>
<td>{{ peer.public_key }}</td>
</tr>
<tr class="peer-preshared-key">
<th>{% trans "Pre-shared key:" %}</th>
<td>{{ peer.preshared_key }}</td>
</tr>
<tr class="server-public-key">
<th>{% trans "Public key of this machine:" %}</th>
<td>{{ server.public_key }}</td>
</tr>
<tr class="server-ip-address-and-network">
<th>{% trans "IP address of this machine:" %}</th>
<td>{{ server.ip_address_and_network }}</td>
</tr>
<tr class="server-default-route">
<th>
{% trans "All outgoing traffic is sent using this connection:" %}
</th>
<td>{% if server.default_route %}
{% trans "Yes" %}
{% else %}
{% trans "No" %}
{% endif %}
</td>
</tr>
</tbody>
</table>
</div>
<h3>{% trans "Status" %}</h3>
<div class="table-responsive">
<table class="table">
<tbody>
<tr class="peer-transfer-tx">
<th>{% trans "Data transmitted:" %}</th>
<td>{{ peer.status.transfer_tx|filesizeformat }}</td>
</tr>
<tr class="peer-transfer-rx">
<th>{% trans "Data received:" %}</th>
<td>{{ peer.status.transfer_rx|filesizeformat }}</td>
</tr>
<tr class="peer-latest-handshake">
<th>{% trans "Latest handshake:" %}</th>
<td>{{ peer.status.latest_handshake|default:'' }}</td>
</tr>
</tbody>
</table>
</div>
{% endif %}
{% endfor %}
<div class="btn-toolbar">
<a class="btn btn-default btn-edit-server"
href="{% url 'wireguard:edit-server' interface %}">
<span class="fa fa-pencil-square-o" aria-hidden="true"></span>
{% trans "Edit" %}
</a>
<a class="btn btn-default btn-delete-server"
href="{% url 'wireguard:delete-server' interface %}">
<span class="fa fa-trash-o" aria-hidden="true"></span>
{% trans "Delete" %}
</a>
</div>
{% endblock %}