wireguard: Create view to handle client config actions

Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Frederico Gomes authored and James Valleroy committed 2026-05-23 08:54:32 -04:00
1 parent 60a6ac2a0d
commit 8e9b2a0631
1 file changed
+15 -1
+15 -1
View File
@@ -7,7 +7,7 @@ import urllib.parse
from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
from django.http import Http404
from django.http import Http404, HttpResponse
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.utils.translation import gettext as _
@@ -112,6 +112,20 @@ class SessionClientDataMixin:
)
class ClientActionsView(SessionClientDataMixin, View):
action = None
def get(self, request):
if self.action == 'download':
config = self.get_client_config(request)
response = HttpResponse(config, content_type='text/plain')
response['Content-Disposition'] = \
'attachment; filename="wg-client.conf"'
return response
raise Http404("Invalid action")
class AutoAddClientView(SuccessMessageMixin, FormView):
"""View to add a client with keypair generation."""
form_class = forms.AutoAddClientForm