wireguard: Cosmetic fixes by yapf and isort

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-10-30 14:39:24 -07:00 committed by James Valleroy
parent 6a2942a9c4
commit fe182a0faa
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 11 additions and 11 deletions

View File

@ -114,23 +114,24 @@ def subcommand_setup(_):
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
check=True)
except subprocess.CalledProcessError:
subprocess.run(
['ip', 'link', 'add', 'dev', SERVER_INTERFACE, 'type',
'wireguard'], check=True)
subprocess.run([
'ip', 'link', 'add', 'dev', SERVER_INTERFACE, 'type', 'wireguard'
], check=True)
if not (PUBLIC_KEY_PATH.exists() and PRIVATE_KEY_PATH.exists()):
_generate_key_pair()
# Configure interface.
subprocess.run(
['wg', 'set', SERVER_INTERFACE, 'listen-port', '51820', 'private-key',
str(PRIVATE_KEY_PATH)], check=True)
subprocess.run([
'wg', 'set', SERVER_INTERFACE, 'listen-port', '51820', 'private-key',
str(PRIVATE_KEY_PATH)
], check=True)
def _get_info():
"""Return info for each configured interface."""
output = subprocess.check_output(
['wg', 'show', 'all', 'dump']).decode().strip()
output = subprocess.check_output(['wg', 'show', 'all',
'dump']).decode().strip()
lines = output.split('\n')
interfaces = {}
for line in lines:
@ -183,8 +184,8 @@ def subcommand_remove_client(arguments):
def _find_next_interface():
"""Find next unused wireguard interface name."""
output = subprocess.check_output(
['wg', 'show', 'interfaces']).decode().strip()
output = subprocess.check_output(['wg', 'show',
'interfaces']).decode().strip()
interfaces = output.split()
interface_num = 1
new_interface_name = 'wg1'

View File

@ -31,7 +31,6 @@ from plinth.utils import format_lazy
from .manifest import clients # noqa, pylint: disable=unused-import
version = 1
managed_packages = ['wireguard']