mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
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:
parent
60a6ac2a0d
commit
8e9b2a0631
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user