summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/eip
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-10-01 17:34:24 -0400
committerKali Kaneko <kali@leap.se>2013-10-03 13:14:34 -0400
commit689c716b831047c8fe18945956e809b74e4250a3 (patch)
treec1f3b1f82abe2d29a6232f6b4bda1d4404a44555 /src/leap/bitmask/services/eip
parente9c84a3d2d9fd3a0457f256a908cb5bce9351682 (diff)
Disable EIP on/off button and action when login required.
Also adds an explicit should_autostart flag in config.
Diffstat (limited to 'src/leap/bitmask/services/eip')
-rw-r--r--src/leap/bitmask/services/eip/eipconfig.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/leap/bitmask/services/eip/eipconfig.py b/src/leap/bitmask/services/eip/eipconfig.py
index 7d8995b4..16ed4cc0 100644
--- a/src/leap/bitmask/services/eip/eipconfig.py
+++ b/src/leap/bitmask/services/eip/eipconfig.py
@@ -33,6 +33,45 @@ from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
+def get_eipconfig_path(domain):
+ """
+ Returns relative path for EIP config.
+
+ :param domain: the domain to which this eipconfig belongs to.
+ :type domain: str
+ :returns: the path
+ :rtype: str
+ """
+ leap_assert(domain is not None, "get_eipconfig_path: We need a domain")
+ return os.path.join("leap", "providers", domain, "eip-service.json")
+
+
+def load_eipconfig_if_needed(provider_config, eip_config, domain):
+ """
+ Utility function to prime a eip_config object from a loaded
+ provider_config and the chosen provider domain.
+
+ :param provider_config: a loaded instance of ProviderConfig
+ :type provider_config: ProviderConfig
+
+ :param eip_config: the eipconfig object to be primed.
+ :type eip_config: EIPConfig
+
+ :param domain: the chosen provider domain
+ :type domain: str
+
+ :returns: Whether the eip_config object has been succesfully loaded
+ :rtype: bool
+ """
+ loaded = eip_config.loaded()
+ if not loaded:
+ eip_config_path = get_eipconfig_path(domain)
+ api_version = provider_config.get_api_version()
+ eip_config.set_api_version(api_version)
+ loaded = eip_config.load(eip_config_path)
+ return loaded
+
+
class VPNGatewaySelector(object):
"""
VPN Gateway selector.
@@ -59,7 +98,6 @@ class VPNGatewaySelector(object):
tz_offset = self.equivalent_timezones[tz_offset]
self._local_offset = tz_offset
-
self._eipconfig = eipconfig
def get_gateways_list(self):