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