diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-04-11 00:48:09 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-04-11 11:25:59 +0200 |
commit | 2928a338dee759d8635b87fc96abe090ebad80e5 (patch) | |
tree | bb891b1667bc5acc827b45de15b6c903d29759d2 | |
parent | 20da27d779ad0d0c9bb78a0f661bc580abcf208e (diff) | |
download | vyos-1x-2928a338dee759d8635b87fc96abe090ebad80e5.tar.gz vyos-1x-2928a338dee759d8635b87fc96abe090ebad80e5.zip |
vpn: l2tp: T2264: proper set PPP default values to ease Jinja2 template
-rw-r--r-- | data/templates/l2tp/l2tp.config.tmpl | 16 | ||||
-rwxr-xr-x | src/conf_mode/vpn_l2tp.py | 38 |
2 files changed, 20 insertions, 34 deletions
diff --git a/data/templates/l2tp/l2tp.config.tmpl b/data/templates/l2tp/l2tp.config.tmpl index 6ebbf1241..f4746a6a1 100644 --- a/data/templates/l2tp/l2tp.config.tmpl +++ b/data/templates/l2tp/l2tp.config.tmpl @@ -105,19 +105,9 @@ bind={{ radius_source_address }} verbose=1 check-ip=1 single-session=replace -{% if idle_timeout %} -lcp-echo-timeout={{idle_timeout}} -{% endif %} -{% if ppp_options['lcp-echo-interval'] %} -lcp-echo-interval={{ppp_options['lcp-echo-interval']}} -{% else %} -lcp-echo-interval=30 -{% endif %} -{% if ppp_options['lcp-echo-failure'] %} -lcp-echo-failure={{ppp_options['lcp-echo-failure']}} -{% else %} -lcp-echo-failure=3 -{% endif %} +lcp-echo-timeout={{ ppp_echo_timeout }} +lcp-echo-interval={{ ppp_echo_interval }} +lcp-echo-failure={{ ppp_echo_failure }} {% if ccp_disable %} ccp=0 {% endif %} diff --git a/src/conf_mode/vpn_l2tp.py b/src/conf_mode/vpn_l2tp.py index 1058eeac6..bb51b4573 100755 --- a/src/conf_mode/vpn_l2tp.py +++ b/src/conf_mode/vpn_l2tp.py @@ -50,6 +50,9 @@ default_config_data = { 'mtu': '1436', 'outside_addr': '', 'ppp_mppe': 'prefer', + 'ppp_echo_failure' : '3', + 'ppp_echo_interval' : '30', + 'ppp_echo_timeout': '0', 'radius_server': [], 'radius_acct_tmo': '3', 'radius_max_try': '3', @@ -282,29 +285,22 @@ def get_config(): 'client-ip-pool subnet')[0]) l2tp['gateway_address'] = lst_ip[0] + # LNS secret + if conf.exists(['lns', 'shared-secret']): + l2tp['lns_shared_secret'] = conf.return_value(['lns', 'shared-secret']) - if conf.exists('idle'): - l2tp['idle_timeout'] = conf.return_value('idle') + if conf.exists(['ccp-disable']): + l2tp[['ccp_disable']] = True - # LNS secret - if conf.exists('lns shared-secret'): - l2tp['lns_shared_secret'] = conf.return_value('lns shared-secret') - - if conf.exists('ccp-disable'): - l2tp['ccp_disable'] = True - - # ppp_options - ppp_options = {} - if conf.exists('ppp-options'): - if conf.exists('ppp-options lcp-echo-failure'): - ppp_options['lcp-echo-failure'] = conf.return_value( - 'ppp-options lcp-echo-failure') - if conf.exists('ppp-options lcp-echo-interval'): - ppp_options['lcp-echo-interval'] = conf.return_value( - 'ppp-options lcp-echo-interval') - - if len(ppp_options) != 0: - l2tp['ppp_options'] = ppp_options + # PPP options + if conf.exists(['idle']): + l2tp['ppp_echo_timeout'] = conf.return_value(['idle']) + + if conf.exists(['ppp-options', 'lcp-echo-failure']): + l2tp['ppp_echo_failure'] = conf.return_value(['ppp-options', 'lcp-echo-failure']) + + if conf.exists(['ppp-options', 'lcp-echo-interval']): + l2tp['ppp_echo_interval'] = conf.return_value(['ppp-options', 'lcp-echo-interval']) import pprint pprint.pprint(l2tp) |