diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-09-30 20:45:10 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-09-30 20:46:04 +0200 |
commit | 5b640551fdff979275b49965801ad438938fb067 (patch) | |
tree | 0be12e9b91cacc5236b7c89980b3367da773a7df /src/conf_mode | |
parent | 458f195c1a57e1eadb0d0eb26310025850a65593 (diff) | |
download | vyos-1x-5b640551fdff979275b49965801ad438938fb067.tar.gz vyos-1x-5b640551fdff979275b49965801ad438938fb067.zip |
wireguard: T2939: bugfix when removing individual peers
When individual peers that have been removed got determined they have been
added to the config dict as list instead of string - which broke the system
plumbing commands as they can not handle a Python list.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/interfaces-wireguard.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py index d5800264f..9bda35d0a 100755 --- a/src/conf_mode/interfaces-wireguard.py +++ b/src/conf_mode/interfaces-wireguard.py @@ -57,13 +57,13 @@ def get_config(config=None): # Determine which Wireguard peer has been removed. # Peers can only be removed with their public key! + dict = {} tmp = node_changed(conf, ['peer']) - if tmp: - dict = {} - for peer in tmp: - peer_config = leaf_node_changed(conf, ['peer', peer, 'pubkey']) - dict = dict_merge({'peer_remove' : {peer : {'pubkey' : peer_config}}}, dict) - wireguard.update(dict) + for peer in (tmp or []): + pubkey = leaf_node_changed(conf, ['peer', peer, 'pubkey']) + if pubkey: + dict = dict_merge({'peer_remove' : {peer : {'pubkey' : pubkey[0]}}}, dict) + wireguard.update(dict) return wireguard @@ -101,12 +101,12 @@ def verify(wireguard): f'for peer "{tmp}" if either one of them is set!') def apply(wireguard): + tmp = WireGuardIf(wireguard['ifname']) if 'deleted' in wireguard: - WireGuardIf(wireguard['ifname']).remove() + tmp.remove() return None - w = WireGuardIf(wireguard['ifname']) - w.update(wireguard) + tmp.update(wireguard) return None if __name__ == '__main__': |