From 182dd2738f077079a47d3f56033b78dac9204986 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 23 Jul 2015 18:45:08 -0300 Subject: [bug] handle eip-config not providing locations Is valid for a provider not to provide locations for their gateways. - Resolves: #7281 --- src/leap/bitmask/backend/components.py | 4 +++- src/leap/bitmask/services/eip/eipconfig.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/backend/components.py b/src/leap/bitmask/backend/components.py index b833bf59..5f34d290 100644 --- a/src/leap/bitmask/backend/components.py +++ b/src/leap/bitmask/backend/components.py @@ -628,7 +628,9 @@ class EIP(object): # this only works for selecting the first gateway, as we're # currently doing. ccodes = gateway_selector.get_gateways_country_code() - gateway_ccode = ccodes[gateways[0]] + gateway_ccode = '' # '' instead of None due to needed signal argument + if ccodes is not None: + gateway_ccode = ccodes[gateways[0]] self._signaler.signal(self._signaler.eip_get_gateway_country_code, gateway_ccode) diff --git a/src/leap/bitmask/services/eip/eipconfig.py b/src/leap/bitmask/services/eip/eipconfig.py index b1d08393..43328af9 100644 --- a/src/leap/bitmask/services/eip/eipconfig.py +++ b/src/leap/bitmask/services/eip/eipconfig.py @@ -161,12 +161,17 @@ class VPNGatewaySelector(object): def get_gateways_country_code(self): """ Return a dict with ipaddress -> country code mapping. + Return None if there are no locations specified. - :rtype: dict + :rtype: dict or None """ country_codes = {} locations = self._eipconfig.get_locations() + + if not locations: + return + gateways = self._eipconfig.get_gateways() for idx, gateway in enumerate(gateways): -- cgit v1.2.3