mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
wireguard: Don't error out when wg0 server is not setup
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
fe182a0faa
commit
ad53848983
@ -135,6 +135,9 @@ def _get_info():
|
||||
lines = output.split('\n')
|
||||
interfaces = {}
|
||||
for line in lines:
|
||||
if not line:
|
||||
continue
|
||||
|
||||
fields = line.split()
|
||||
interface_name = fields[0]
|
||||
if interface_name in interfaces:
|
||||
@ -247,7 +250,7 @@ def subcommand_add_server(arguments):
|
||||
def subcommand_modify_server(arguments):
|
||||
"""Modify a server."""
|
||||
interfaces = _get_info()
|
||||
interfaces.pop(SERVER_INTERFACE)
|
||||
interfaces.pop(SERVER_INTERFACE, None)
|
||||
interface_to_modify = None
|
||||
for interface in interfaces.values():
|
||||
if interface['peers']:
|
||||
@ -280,7 +283,7 @@ def subcommand_modify_server(arguments):
|
||||
def subcommand_remove_server(arguments):
|
||||
"""Remove a server."""
|
||||
interfaces = _get_info()
|
||||
interfaces.pop(SERVER_INTERFACE)
|
||||
interfaces.pop(SERVER_INTERFACE, None)
|
||||
interface_to_remove = None
|
||||
for interface in interfaces.values():
|
||||
if interface['peers']:
|
||||
|
||||
@ -120,7 +120,7 @@ def get_info():
|
||||
"""Return server and clients info."""
|
||||
output = actions.superuser_run('wireguard', ['get-info'])
|
||||
info = json.loads(output)
|
||||
my_server_info = info.pop(SERVER_INTERFACE)
|
||||
my_server_info = info.pop(SERVER_INTERFACE, {})
|
||||
my_client_servers = []
|
||||
for interface in info.values():
|
||||
if interface['peers']:
|
||||
@ -128,8 +128,8 @@ def get_info():
|
||||
|
||||
return {
|
||||
'my_server': {
|
||||
'public_key': my_server_info['public_key'],
|
||||
'clients': my_server_info['peers'],
|
||||
'public_key': my_server_info.get('public_key'),
|
||||
'clients': my_server_info.get('peers'),
|
||||
},
|
||||
'my_client': {
|
||||
'servers': my_client_servers,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user