wireguard: Add action for QR code generation

Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Frederico Gomes 2026-03-24 11:01:42 +00:00 committed by James Valleroy
parent 68e28cdebc
commit 18d6f2d5db
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -3,6 +3,7 @@
Views for WireGuard application.
"""
import segno
import urllib.parse
from django.contrib import messages
@ -13,6 +14,8 @@ from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import FormView, TemplateView, View
from io import BytesIO
from plinth import network
from plinth.modules.names.components import DomainName
from plinth.views import AppView
@ -122,6 +125,13 @@ class ClientActionsView(SessionClientDataMixin, View):
response['Content-Disposition'] = \
'attachment; filename="wg-client.conf"'
return response
elif self.action == 'qr':
qrcode = segno.make(config)
buffer = BytesIO()
qrcode.save(buffer, kind='svg', scale=5)
return HttpResponse(buffer.getvalue(),
content_type='image/svg+xml')
raise Http404("Invalid action")