summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2018-08-17 22:38:06 +0000
committerhagbard <vyosdev@derith.de>2018-08-17 22:38:06 +0000
commit14f37d3ecbab133b0259de540ae16bd065494dd7 (patch)
tree7e65fd74b218110844c831f75ac501e0c46e32c7 /src
parentf184700bdb0c070be7f3bf9d9b2712581c29e798 (diff)
downloadvyos-1x-14f37d3ecbab133b0259de540ae16bd065494dd7.tar.gz
vyos-1x-14f37d3ecbab133b0259de540ae16bd065494dd7.zip
T783: to disable keepalive is has to be set to 0.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/wireguard.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/conf_mode/wireguard.py b/src/conf_mode/wireguard.py
index 94378a6ef..e1c076e2a 100755
--- a/src/conf_mode/wireguard.py
+++ b/src/conf_mode/wireguard.py
@@ -196,11 +196,27 @@ def apply(c):
### persistent-keepalive
for p in c_eff.list_nodes(intf + ' peer'):
- pklv_eff = c_eff.return_effective_value(intf + ' peer ' + p + ' persistent-keepalive')
- pklv = c_eff.return_value(intf + ' peer ' + p + ' persistent-keepalive')
- if pklv_eff == pklv:
+ val_eff = ""
+ val = ""
+
+ if c_eff.exists_effective(intf + ' peer ' + p + ' persistent-keepalive'):
+ val_eff = c_eff.return_effective_value(intf + ' peer ' + p + ' persistent-keepalive')
+
+ if 'persistent-keepalive' in c['interfaces'][intf]['peer'][p]:
+ val = c['interfaces'][intf]['peer'][p]['persistent-keepalive']
+
+ ### disable keepalive
+ if val_eff and not val:
+ c['interfaces'][intf]['peer'][p]['persistent-keepalive'] = 0
+
+ ### set ne keepalive value
+ if not val_eff and val:
+ c['interfaces'][intf]['peer'][p]['persistent-keepalive'] = val
+
+ ## config == effective config, no change
+ if val_eff == val:
del c['interfaces'][intf]['peer'][p]['persistent-keepalive']
-
+
## wg command call
configure_interface(c,intf)
@@ -228,7 +244,7 @@ def configure_interface(c, intf):
if c['interfaces'][intf]['peer'][p]['endpoint']:
cmd += " endpoint " + c['interfaces'][intf]['peer'][p]['endpoint']
- if c['interfaces'][intf]['peer'][p]['persistent-keepalive']:
+ if 'persistent-keepalive' in c['interfaces'][intf]['peer'][p]:
cmd += " persistent-keepalive " + str( c['interfaces'][intf]['peer'][p]['persistent-keepalive'])
sl.syslog(sl.LOG_NOTICE, "sudo " + cmd)