summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJernej Jakob <jernej.jakob@gmail.com>2020-04-14 21:58:53 +0200
committerJernej Jakob <jernej.jakob@gmail.com>2020-04-14 22:03:26 +0200
commit9b6a3695ea2cc2884943edc8d752ea639735bbb5 (patch)
treeeb6c330ed24a0517d32e8e64cc44b204ca7ba27a
parent9bcfdc20ade97b2d746bbe1b8506524aae710ca2 (diff)
downloadvyos-1x-9b6a3695ea2cc2884943edc8d752ea639735bbb5.tar.gz
vyos-1x-9b6a3695ea2cc2884943edc8d752ea639735bbb5.zip
openvpn: T2293: fix UnboundLocalError if server subnet is unset
Commit bb36bde introduced a bug when server subnet is unset, this fixes it.
-rwxr-xr-xsrc/conf_mode/interfaces-openvpn.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py
index b42765586..79def4e45 100755
--- a/src/conf_mode/interfaces-openvpn.py
+++ b/src/conf_mode/interfaces-openvpn.py
@@ -124,13 +124,10 @@ def getDefaultServer(network, topology, devtype):
Logic from openvpn's src/openvpn/helper.c.
Returns a dict with addresses or False if the input parameters were incorrect.
"""
- if not (topology and devtype):
- return False
-
if not (devtype == 'tun' or devtype == 'tap'):
return False
- if not network.prefixlen:
+ if not network.version == 4:
return False
elif (devtype == 'tun' and network.prefixlen > 29) or (devtype == 'tap' and network.prefixlen > 30):
return False
@@ -477,9 +474,10 @@ def get_config():
openvpn['tls_dh'] = 'none'
# Set defaults where necessary.
- # If any of the input parameters are missing or wrong,
+ # If any of the input parameters are wrong,
# this will return False and no defaults will be set.
- default_server = getDefaultServer(server_network, openvpn['server_topology'], openvpn['type'])
+ if server_network and openvpn['server_topology'] and openvpn['type']:
+ 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']: