mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
wireguard: Move segno import inside method
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
efcdc8cb5c
commit
629cc866b6
@ -3,7 +3,6 @@
|
|||||||
Views for WireGuard application.
|
Views for WireGuard application.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import segno
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
@ -99,26 +98,25 @@ class SessionClientDataMixin:
|
|||||||
raise Http404("Session expired")
|
raise Http404("Session expired")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'next_ip': next_ip,
|
'next_ip': next_ip,
|
||||||
'privkey': privkey,
|
'privkey': privkey,
|
||||||
'pubkey': pubkey,
|
'pubkey': pubkey,
|
||||||
'endpoint': endpoint
|
'endpoint': endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_client_config(self, request):
|
def get_client_config(self, request):
|
||||||
"""Rebuild client config from session."""
|
"""Rebuild client config from session."""
|
||||||
data = self.get_session_client_data(request)
|
data = self.get_session_client_data(request)
|
||||||
|
|
||||||
return utils.build_client_config(
|
return utils.build_client_config(data['next_ip'], data['privkey'],
|
||||||
data['next_ip'], data['privkey'],
|
data['pubkey'], data['endpoint'])
|
||||||
data['pubkey'], data['endpoint']
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ClientActionsView(SessionClientDataMixin, View):
|
class ClientActionsView(SessionClientDataMixin, View):
|
||||||
action = None
|
action = None
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
import segno
|
||||||
if self.action == 'download':
|
if self.action == 'download':
|
||||||
config = self.get_client_config(request)
|
config = self.get_client_config(request)
|
||||||
response = HttpResponse(config, content_type='text/plain')
|
response = HttpResponse(config, content_type='text/plain')
|
||||||
@ -174,7 +172,7 @@ class AutoAddClientView(SuccessMessageMixin, FormView):
|
|||||||
'client_privkey': client_privkey,
|
'client_privkey': client_privkey,
|
||||||
'client_pubkey': client_pubkey,
|
'client_pubkey': client_pubkey,
|
||||||
'endpoint': endpoint
|
'endpoint': endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add properties to template context
|
# Add properties to template context
|
||||||
context['domains'] = filtered_domains
|
context['domains'] = filtered_domains
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user