mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
wireguard: Show next available client IP in Add Client form
Display the next available IP address that will be automatically assigned when adding a new client. Helps admins know what client IP to provide when configuring client connections back to this server. Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com> [sunil: Turn the IP address styling into a form element] [sunil: Update the comment style for consistency] [sunil: Update the label for clarity] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
0fa77cbe30
commit
b0a841c63a
@ -15,6 +15,18 @@
|
|||||||
|
|
||||||
{{ form|bootstrap }}
|
{{ form|bootstrap }}
|
||||||
|
|
||||||
|
{% if next_ip %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="id_next_ip" class="control-label">
|
||||||
|
{% trans "IP address that will be assigned to this client" %}
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" id="id_next_ip" class="form-control"
|
||||||
|
value="{{ next_ip }}" disabled="disabled">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary"
|
<input type="submit" class="btn btn-primary"
|
||||||
value="{% trans "Add Client" %}"/>
|
value="{% trans "Add Client" %}"/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -46,6 +46,16 @@ class AddClientView(SuccessMessageMixin, FormView):
|
|||||||
"""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['title'] = _('Add Allowed Client')
|
context['title'] = _('Add Allowed Client')
|
||||||
|
|
||||||
|
# Show next available IP.
|
||||||
|
try:
|
||||||
|
connection = utils._server_connection()
|
||||||
|
setting_name = utils.nm.SETTING_WIREGUARD_SETTING_NAME
|
||||||
|
settings = connection.get_setting_by_name(setting_name)
|
||||||
|
context['next_ip'] = utils._get_next_available_ip_address(settings)
|
||||||
|
except Exception:
|
||||||
|
context['next_ip'] = None
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user