diff options
author | kali <kali@leap.se> | 2013-05-07 22:51:08 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-05-07 22:51:08 +0900 |
commit | 3f304a2241196edda14deb9fcbe595b434a08ff2 (patch) | |
tree | f9b77db03b74fc069b0c48fe47d2a3e5894047d8 /src | |
parent | fd60462163c6a27bf8a7e394a62f75ccab462fae (diff) |
use ipaddr to get ipv6 support
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/services/eip/eipconfig.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/leap/services/eip/eipconfig.py b/src/leap/services/eip/eipconfig.py index e6b93647..0a7d2b23 100644 --- a/src/leap/services/eip/eipconfig.py +++ b/src/leap/services/eip/eipconfig.py @@ -22,6 +22,8 @@ import logging import os import re +import ipaddr + from leap.common.check import leap_assert, leap_assert_type from leap.common.config.baseconfig import BaseConfig from leap.config.providerconfig import ProviderConfig @@ -36,7 +38,6 @@ class EIPConfig(BaseConfig): """ OPENVPN_ALLOWED_KEYS = ("auth", "cipher", "tls-cipher") OPENVPN_CIPHERS_REGEX = re.compile("[A-Z0-9\-]+") - IP_REGEX = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") def __init__(self): BaseConfig.__init__(self) @@ -91,9 +92,14 @@ class EIPConfig(BaseConfig): index = 0 logger.warning("Provided an unknown gateway index %s, " + "defaulting to 0") - ip_addr = gateways[0]["ip_address"] - if self.IP_REGEX.search(ip_addr): - return ip_addr + ip_addr_str = gateways[0]["ip_address"] + + try: + ipaddr.IPAddress(ip_addr_str) + return ip_addr_str + except ValueError: + logger.error("Invalid ip address in config: %s" % (ip_addr_str,)) + return None def get_client_cert_path(self, providerconfig=None, |