diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-04-15 18:33:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 18:33:00 +0200 |
commit | 011bb3423567d659c5af87bb99fac357560d9368 (patch) | |
tree | e9cb7b672ed2036d6db7217e69b747c41272d50d /src/conf_mode/interfaces-openvpn.py | |
parent | 079ffb7a850bf97d702fcc01a6a4b64ff583ea19 (diff) | |
parent | 3561b1b7b735cec165cb4a71957a6ed9066ad208 (diff) | |
download | vyos-1x-011bb3423567d659c5af87bb99fac357560d9368.tar.gz vyos-1x-011bb3423567d659c5af87bb99fac357560d9368.zip |
Merge pull request #348 from jjakob/openvpn-exception-fix
openvpn: T2293: fix UnboundLocalError if server subnet is unset
Diffstat (limited to 'src/conf_mode/interfaces-openvpn.py')
-rwxr-xr-x | src/conf_mode/interfaces-openvpn.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py index 79def4e45..6733623c6 100755 --- a/src/conf_mode/interfaces-openvpn.py +++ b/src/conf_mode/interfaces-openvpn.py @@ -79,7 +79,7 @@ default_config_data = { 'server_push_route': [], 'server_reject_unconfigured': False, 'server_subnet': '', - 'server_topology': 'net30', + 'server_topology': '', 'shared_secret_file': '', 'tls': False, 'tls_auth': '', @@ -342,6 +342,7 @@ def get_config(): openvpn['server_topology'] = conf.return_value('server topology') # Server-mode subnet (from which client IPs are allocated) + server_network = None if conf.exists('server subnet'): # server_network is used later in this function server_network = IPv4Network(conf.return_value('server subnet')) @@ -473,26 +474,31 @@ def get_config(): if not openvpn['tls_dh'] and openvpn['tls_key'] and checkCertHeader('-----BEGIN EC PRIVATE KEY-----', openvpn['tls_key']): openvpn['tls_dh'] = 'none' + # set default server topology to net30 + if openvpn['mode'] == 'server' and not openvpn['server_topology']: + openvpn['server_topology'] = 'net30' + # Set defaults where necessary. # If any of the input parameters are wrong, # this will return False and no defaults will be set. if server_network and openvpn['server_topology'] and openvpn['type']: + default_server = None default_server = getDefaultServer(server_network, openvpn['server_topology'], openvpn['type']) - if default_server: - # server-bridge doesn't require a pool so don't set defaults for it - if not openvpn['bridge_member']: - openvpn['server_pool'] = True - if not openvpn['server_pool_start']: - openvpn['server_pool_start'] = default_server['pool_start'] + if default_server: + # server-bridge doesn't require a pool so don't set defaults for it + if not openvpn['bridge_member']: + openvpn['server_pool'] = True + if not openvpn['server_pool_start']: + openvpn['server_pool_start'] = default_server['pool_start'] - if not openvpn['server_pool_stop']: - openvpn['server_pool_stop'] = default_server['pool_stop'] + if not openvpn['server_pool_stop']: + openvpn['server_pool_stop'] = default_server['pool_stop'] - if not openvpn['server_pool_netmask']: - openvpn['server_pool_netmask'] = default_server['pool_netmask'] + if not openvpn['server_pool_netmask']: + openvpn['server_pool_netmask'] = default_server['pool_netmask'] - for client in openvpn['client']: - client['remote_netmask'] = default_server['client_remote_netmask'] + for client in openvpn['client']: + client['remote_netmask'] = default_server['client_remote_netmask'] return openvpn |