Peer list with details

This commit is contained in:
Eduardo Silva
2024-02-17 11:53:51 -03:00
parent 0a14192444
commit cfcabed244
13 changed files with 207 additions and 8 deletions

View File

@@ -30,6 +30,9 @@ class PeerAllowedIPForm(forms.ModelForm):
priority = cleaned_data.get('priority')
allowed_ip = cleaned_data.get('allowed_ip')
netmask = cleaned_data.get('netmask')
if allowed_ip is None:
raise forms.ValidationError("Please provide a valid IP address.")
wireguard_network = ipaddress.ip_network(f"{self.current_peer.wireguard_instance.address}/{self.current_peer.wireguard_instance.netmask}", strict=False)
if priority == 0:

View File

@@ -119,7 +119,7 @@ def view_wireguard_peer_manage(request):
if current_peer.name:
page_title += current_peer.name
else:
page_title += current_peer.public_key
page_title += current_peer.public_key[:16] + ("..." if len(current_peer.public_key) > 16 else "")
if request.method == 'POST':
form = PeerForm(request.POST, instance=current_peer)
if form.is_valid():
@@ -157,7 +157,7 @@ def view_manage_ip_address(request):
if current_peer.name:
page_title += current_peer.name
else:
page_title += current_peer.public_key
page_title += current_peer.public_key[:10] + ("..." if len(current_peer.public_key) > 16 else "")
if request.GET.get('action') == 'delete':
if request.GET.get('confirmation') == 'delete':
current_ip.delete()