diff options
author | hagbard <vyosdev@derith.de> | 2018-08-17 19:32:47 +0000 |
---|---|---|
committer | hagbard <vyosdev@derith.de> | 2018-08-17 19:32:47 +0000 |
commit | f184700bdb0c070be7f3bf9d9b2712581c29e798 (patch) | |
tree | e7d608874d96af2df8562c323d2bdc7235f218d9 /src/conf_mode | |
parent | 85a80fe59443a91b66185a06e192f99bec30af68 (diff) | |
download | vyos-1x-f184700bdb0c070be7f3bf9d9b2712581c29e798.tar.gz vyos-1x-f184700bdb0c070be7f3bf9d9b2712581c29e798.zip |
T783: conf mode persistent-keepalive implementation
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/wireguard.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/conf_mode/wireguard.py b/src/conf_mode/wireguard.py index dda5c4d8a..94378a6ef 100755 --- a/src/conf_mode/wireguard.py +++ b/src/conf_mode/wireguard.py @@ -116,6 +116,10 @@ def get_config(): if c.exists(cnf + ' peer ' + p + ' endpoint'): config_data['interfaces'][intfc]['peer'][p]['endpoint'] = c.return_value(cnf + ' peer ' + p + ' endpoint') + ### persistent-keepalive + if c.exists(cnf + ' peer ' + p + ' persistent-keepalive'): + config_data['interfaces'][intfc]['peer'][p]['persistent-keepalive'] = c.return_value(cnf + ' peer ' + p + ' persistent-keepalive') + #print (config_data) return config_data @@ -190,6 +194,14 @@ def apply(c): for addr in addr_add: add_addr(intf, addr) + ### 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: + del c['interfaces'][intf]['peer'][p]['persistent-keepalive'] + + ## wg command call configure_interface(c,intf) ### ifalias for snmp from description @@ -216,6 +228,9 @@ 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']: + cmd += " persistent-keepalive " + str( c['interfaces'][intf]['peer'][p]['persistent-keepalive']) + sl.syslog(sl.LOG_NOTICE, "sudo " + cmd) subprocess.call([ 'sudo ' + cmd], shell=True) |