summaryrefslogtreecommitdiff
path: root/src/leap/services
diff options
context:
space:
mode:
authorkali <kali@leap.se>2013-05-07 22:51:08 +0900
committerkali <kali@leap.se>2013-05-11 21:59:59 +0900
commit7126aad25c3dd45bfe026ba1ad383bf5476ffb15 (patch)
treeab1e5b142e5a7f4d82f2f5e0ad9c1eee665d9475 /src/leap/services
parent2dae2703fb8c2ae7e721ce83020c0dd10ff9ca33 (diff)
use ipaddr to get ipv6 support
Diffstat (limited to 'src/leap/services')
-rw-r--r--src/leap/services/eip/eipconfig.py14
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,