summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-wireguard.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-28 10:49:47 +0200
committerGitHub <noreply@github.com>2021-08-28 10:49:47 +0200
commitdd4e2b544b3b2027c62a4e8b3ca6033ab90001a1 (patch)
tree765ae0ef5aeea8d302a0b8762c0b392cb7960c12 /src/conf_mode/interfaces-wireguard.py
parentda29092d3d40a3b140fcb500bb8ae275cbf367fa (diff)
parenteb11d4b688d883d0c1d150b00eee40b54df42b32 (diff)
downloadvyos-1x-dd4e2b544b3b2027c62a4e8b3ca6033ab90001a1.tar.gz
vyos-1x-dd4e2b544b3b2027c62a4e8b3ca6033ab90001a1.zip
Merge pull request #980 from zdc/T3763-sagitta
wireguard: T3763: Added check for listening port availability
Diffstat (limited to 'src/conf_mode/interfaces-wireguard.py')
-rwxr-xr-xsrc/conf_mode/interfaces-wireguard.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py
index 4c566a5ad..68181465e 100755
--- a/src/conf_mode/interfaces-wireguard.py
+++ b/src/conf_mode/interfaces-wireguard.py
@@ -30,6 +30,7 @@ from vyos.configverify import verify_bridge_delete
from vyos.configverify import verify_mtu_ipv6
from vyos.ifconfig import WireGuardIf
from vyos.util import check_kmod
+from vyos.util import check_port_availability
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -73,6 +74,13 @@ def verify(wireguard):
if 'peer' not in wireguard:
raise ConfigError('At least one Wireguard peer is required!')
+ listen_port = int(wireguard['port'])
+ if 'port' in wireguard and check_port_availability('0.0.0.0', listen_port,
+ 'udp') is not True:
+ raise ConfigError(
+ f'The UDP port {listen_port} is busy or unavailable and cannot be used for the interface'
+ )
+
# run checks on individual configured WireGuard peer
for tmp in wireguard['peer']:
peer = wireguard['peer'][tmp]