mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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:
parent
6a2942a9c4
commit
fe182a0faa
@ -114,23 +114,24 @@ def subcommand_setup(_):
|
|||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||||
check=True)
|
check=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
subprocess.run(
|
subprocess.run([
|
||||||
['ip', 'link', 'add', 'dev', SERVER_INTERFACE, 'type',
|
'ip', 'link', 'add', 'dev', SERVER_INTERFACE, 'type', 'wireguard'
|
||||||
'wireguard'], check=True)
|
], check=True)
|
||||||
|
|
||||||
if not (PUBLIC_KEY_PATH.exists() and PRIVATE_KEY_PATH.exists()):
|
if not (PUBLIC_KEY_PATH.exists() and PRIVATE_KEY_PATH.exists()):
|
||||||
_generate_key_pair()
|
_generate_key_pair()
|
||||||
|
|
||||||
# Configure interface.
|
# Configure interface.
|
||||||
subprocess.run(
|
subprocess.run([
|
||||||
['wg', 'set', SERVER_INTERFACE, 'listen-port', '51820', 'private-key',
|
'wg', 'set', SERVER_INTERFACE, 'listen-port', '51820', 'private-key',
|
||||||
str(PRIVATE_KEY_PATH)], check=True)
|
str(PRIVATE_KEY_PATH)
|
||||||
|
], check=True)
|
||||||
|
|
||||||
|
|
||||||
def _get_info():
|
def _get_info():
|
||||||
"""Return info for each configured interface."""
|
"""Return info for each configured interface."""
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(['wg', 'show', 'all',
|
||||||
['wg', 'show', 'all', 'dump']).decode().strip()
|
'dump']).decode().strip()
|
||||||
lines = output.split('\n')
|
lines = output.split('\n')
|
||||||
interfaces = {}
|
interfaces = {}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -183,8 +184,8 @@ def subcommand_remove_client(arguments):
|
|||||||
|
|
||||||
def _find_next_interface():
|
def _find_next_interface():
|
||||||
"""Find next unused wireguard interface name."""
|
"""Find next unused wireguard interface name."""
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(['wg', 'show',
|
||||||
['wg', 'show', 'interfaces']).decode().strip()
|
'interfaces']).decode().strip()
|
||||||
interfaces = output.split()
|
interfaces = output.split()
|
||||||
interface_num = 1
|
interface_num = 1
|
||||||
new_interface_name = 'wg1'
|
new_interface_name = 'wg1'
|
||||||
|
|||||||
@ -31,7 +31,6 @@ from plinth.utils import format_lazy
|
|||||||
|
|
||||||
from .manifest import clients # noqa, pylint: disable=unused-import
|
from .manifest import clients # noqa, pylint: disable=unused-import
|
||||||
|
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
managed_packages = ['wireguard']
|
managed_packages = ['wireguard']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user