summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-15 07:55:55 +0200
committerGitHub <noreply@github.com>2020-04-15 07:55:55 +0200
commit079ffb7a850bf97d702fcc01a6a4b64ff583ea19 (patch)
treeeb6c330ed24a0517d32e8e64cc44b204ca7ba27a
parent9bcfdc20ade97b2d746bbe1b8506524aae710ca2 (diff)
parent9b6a3695ea2cc2884943edc8d752ea639735bbb5 (diff)
downloadvyos-1x-079ffb7a850bf97d702fcc01a6a4b64ff583ea19.tar.gz
vyos-1x-079ffb7a850bf97d702fcc01a6a4b64ff583ea19.zip
Merge pull request #345 from jjakob/openvpn-pool
openvpn: T2293: fix UnboundLocalError if server subnet is unset
-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']: