diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-08-29 16:00:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-29 16:00:22 +0200 |
commit | afef799f215d47bed81474b01bcead1eb2aa1cd6 (patch) | |
tree | 2cc0a793e3eaf74d6ca7316d7efe01314afebc47 | |
parent | 794f193d11c8c1b5fed78f4e40280480446ab593 (diff) | |
parent | 8d0207f87cf692458b688527022c8d841ec72904 (diff) | |
download | vyos-1x-afef799f215d47bed81474b01bcead1eb2aa1cd6.tar.gz vyos-1x-afef799f215d47bed81474b01bcead1eb2aa1cd6.zip |
Merge pull request #982 from zdc/T3763-sagitta
wireguard: T3763: Fixed uninitialized port issue
-rwxr-xr-x | src/conf_mode/interfaces-wireguard.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py index 68181465e..da64dd076 100755 --- a/src/conf_mode/interfaces-wireguard.py +++ b/src/conf_mode/interfaces-wireguard.py @@ -47,6 +47,9 @@ def get_config(config=None): base = ['interfaces', 'wireguard'] wireguard = get_interface_dict(conf, base) + # Check if a port was changed + wireguard['port_changed'] = leaf_node_changed(conf, ['port']) + # Determine which Wireguard peer has been removed. # Peers can only be removed with their public key! dict = {} @@ -74,12 +77,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 and wireguard['port_changed']: + 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']: |