diff options
author | Marcus Hoff <marcus.hoff@ring2.dk> | 2020-10-03 13:46:22 +0200 |
---|---|---|
committer | Marcus Hoff <marcus.hoff@ring2.dk> | 2020-10-03 13:46:22 +0200 |
commit | 000c18e7ccaf8a7e265b078211837c6fcf3e8179 (patch) | |
tree | 67d87ea5f5541109e9f273c73f71f40ceffdd567 /src/conf_mode/interfaces-wireguard.py | |
parent | 1141bee72677b25d18436975625d2d298be503ff (diff) | |
parent | e4e75aacac93f320a20ad367bdfc8aa2c21596ef (diff) | |
download | vyos-1x-000c18e7ccaf8a7e265b078211837c6fcf3e8179.tar.gz vyos-1x-000c18e7ccaf8a7e265b078211837c6fcf3e8179.zip |
Merge remote-tracking branch 'upstream/current' into current
Diffstat (limited to 'src/conf_mode/interfaces-wireguard.py')
-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__': |