From 14f37d3ecbab133b0259de540ae16bd065494dd7 Mon Sep 17 00:00:00 2001 From: hagbard Date: Fri, 17 Aug 2018 22:38:06 +0000 Subject: T783: to disable keepalive is has to be set to 0. --- src/conf_mode/wireguard.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/conf_mode') 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) -- cgit v1.2.3