summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-wireguard.py
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2021-08-29 15:50:24 +0300
committerzsdc <taras@vyos.io>2021-08-29 15:50:24 +0300
commitc78daaf0f93937a7ecac139c45c5c81f7fcee81f (patch)
tree1966e71ac06207db1863d5bf1249fc53f690eb7c /src/conf_mode/interfaces-wireguard.py
parent26f6168626f79ebc3e027ecf5f77d79a6337d97c (diff)
downloadvyos-1x-c78daaf0f93937a7ecac139c45c5c81f7fcee81f.tar.gz
vyos-1x-c78daaf0f93937a7ecac139c45c5c81f7fcee81f.zip
wireguard: T3763: Fixed uninitialized port issue
The commit fixes the problem, when port availability check is triggered even if a port for WireGuard interface is not defined (randomized port, default behavior).
Diffstat (limited to 'src/conf_mode/interfaces-wireguard.py')
-rwxr-xr-xsrc/conf_mode/interfaces-wireguard.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py
index 68181465e..9baf5b6e9 100755
--- a/src/conf_mode/interfaces-wireguard.py
+++ b/src/conf_mode/interfaces-wireguard.py
@@ -74,12 +74,12 @@ 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'
- )
+ if 'port' in wireguard:
+ listen_port = int(wireguard['port'])
+ if 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']: