summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/base/config.py1
-rw-r--r--src/leap/base/providers.py14
-rw-r--r--src/leap/eip/checks.py4
-rw-r--r--src/leap/eip/config.py19
-rw-r--r--src/leap/eip/eipconnection.py18
-rw-r--r--src/leap/gui/firstrun/last.py1
-rw-r--r--src/leap/gui/firstrun/providerinfo.py9
-rw-r--r--src/leap/gui/firstrun/regvalidation.py9
8 files changed, 51 insertions, 24 deletions
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 9ce2e9f0..0255fbab 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -118,6 +118,7 @@ class JSONLeapConfig(BaseLeapConfig):
" derived class")
assert issubclass(self.spec, PluggableConfig)
+ self.domain = kwargs.pop('domain', None)
self._config = self.spec(format="json")
self._config.load()
self.fetcher = kwargs.pop('fetcher', requests)
diff --git a/src/leap/base/providers.py b/src/leap/base/providers.py
index 7b219cc7..d41f3695 100644
--- a/src/leap/base/providers.py
+++ b/src/leap/base/providers.py
@@ -7,20 +7,20 @@ class LeapProviderDefinition(baseconfig.JSONLeapConfig):
spec = specs.leap_provider_spec
def _get_slug(self):
- provider_path = baseconfig.get_default_provider_path()
+ domain = getattr(self, 'domain', None)
+ if domain:
+ path = baseconfig.get_provider_path(domain)
+ else:
+ path = baseconfig.get_default_provider_path()
+
return baseconfig.get_config_file(
- 'provider.json',
- folder=provider_path)
+ 'provider.json', folder=path)
def _set_slug(self, *args, **kwargs):
raise AttributeError("you cannot set slug")
slug = property(_get_slug, _set_slug)
- # TODO (MVS+)
- # we will construct slug from providers/%s/definition.json
- # where %s is domain name. we can get that on __init__
-
class LeapProviderSet(object):
# we gather them from the filesystem
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index caaef2ea..116c535e 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -450,6 +450,8 @@ class EIPConfigChecker(object):
uri = self._get_provider_definition_uri(domain=domain)
# FIXME! Pass ca path verify!!!
+ # BUG #638
+ # FIXME FIXME FIXME
self.defaultprovider.load(
from_uri=uri,
fetcher=self.fetcher,
@@ -464,7 +466,7 @@ class EIPConfigChecker(object):
config = self.eipserviceconfig.config
if uri is None:
if not domain:
- domain = config.get('provider', None)
+ domain = self.domain or config.get('provider', None)
uri = self._get_eip_service_uri(domain=domain)
self.eipserviceconfig.load(from_uri=uri, fetcher=self.fetcher)
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index 57e15c9e..42c00380 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -35,9 +35,13 @@ class EIPServiceConfig(baseconfig.JSONLeapConfig):
spec = eipspecs.eipservice_config_spec
def _get_slug(self):
+ domain = getattr(self, 'domain', None)
+ if domain:
+ path = baseconfig.get_provider_path(domain)
+ else:
+ path = baseconfig.get_default_provider_path()
return baseconfig.get_config_file(
- 'eip-service.json',
- folder=baseconfig.get_default_provider_path())
+ 'eip-service.json', folder=path)
def _set_slug(self):
raise AttributeError("you cannot set slug")
@@ -53,15 +57,16 @@ def get_socket_path():
return socket_path
-def get_eip_gateway():
+def get_eip_gateway(provider=None):
"""
return the first host in eip service config
that matches the name defined in the eip.json config
file.
"""
placeholder = "testprovider.example.org"
- eipconfig = EIPConfig()
- #import ipdb;ipdb.set_trace()
+ # XXX check for null on provider??
+
+ eipconfig = EIPConfig(domain=provider)
eipconfig.load()
conf = eipconfig.config
@@ -69,7 +74,7 @@ def get_eip_gateway():
if not primary_gateway:
return placeholder
- eipserviceconfig = EIPServiceConfig()
+ eipserviceconfig = EIPServiceConfig(domain=provider)
eipserviceconfig.load()
eipsconf = eipserviceconfig.get_config()
gateways = eipsconf.get('gateways', None)
@@ -134,7 +139,7 @@ def build_ovpn_options(daemon=False, socket_path=None, **kwargs):
# remote
opts.append('--remote')
- gw = get_eip_gateway()
+ gw = get_eip_gateway(provider=provider)
logger.debug('setting eip gateway to %s', gw)
opts.append(str(gw))
opts.append('1194')
diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py
index acd40beb..7828c864 100644
--- a/src/leap/eip/eipconnection.py
+++ b/src/leap/eip/eipconnection.py
@@ -30,6 +30,8 @@ class EIPConnection(OpenVPNConnection):
self.settingsfile = kwargs.get('settingsfile', None)
self.logfile = kwargs.get('logfile', None)
self.provider = kwargs.pop('provider', None)
+ self._providercertchecker = provider_cert_checker
+ self._configchecker = config_checker
self.error_queue = Queue.Queue()
@@ -39,10 +41,7 @@ class EIPConnection(OpenVPNConnection):
checker_signals = kwargs.pop('checker_signals', None)
self.checker_signals = checker_signals
- # initialize checkers
- self.provider_cert_checker = provider_cert_checker(
- domain=self.provider)
- self.config_checker = config_checker(domain=self.provider)
+ self.init_checkers()
host = eipconfig.get_socket_path()
kwargs['host'] = host
@@ -52,13 +51,24 @@ class EIPConnection(OpenVPNConnection):
def has_errors(self):
return True if self.error_queue.qsize() != 0 else False
+ def init_checkers(self):
+ # initialize checkers
+ self.provider_cert_checker = self._providercertchecker(
+ domain=self.provider)
+ self.config_checker = self._configchecker(domain=self.provider)
+
def set_provider_domain(self, domain):
"""
sets the provider domain.
used from the first run wizard when we launch the run_checks
and connect process after having initialized the conductor.
"""
+ # This looks convoluted, right.
+ # We have to reinstantiate checkers cause we're passing
+ # the domain param that we did not know at the beginning
+ # (only for the firstrunwizard case)
self.provider = domain
+ self.init_checkers()
def run_checks(self, skip_download=False, skip_verify=False):
"""
diff --git a/src/leap/gui/firstrun/last.py b/src/leap/gui/firstrun/last.py
index 6f9abbb5..13b2f548 100644
--- a/src/leap/gui/firstrun/last.py
+++ b/src/leap/gui/firstrun/last.py
@@ -28,6 +28,7 @@ class LastPage(QtGui.QWizardPage):
self.label = QtGui.QLabel()
self.label.setWordWrap(True)
+ # XXX REFACTOR to a Validating Page...
self.status_line_1 = QtGui.QLabel()
self.status_line_2 = QtGui.QLabel()
self.status_line_3 = QtGui.QLabel()
diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py
index ef3b32c1..e642fcd0 100644
--- a/src/leap/gui/firstrun/providerinfo.py
+++ b/src/leap/gui/firstrun/providerinfo.py
@@ -99,9 +99,6 @@ class ProviderInfoPage(ValidationPage):
wizard = self.wizard()
prevpage = "providerselection"
- netchecker = wizard.netchecker()
- providercertchecker = wizard.providercertchecker()
- eipconfigchecker = wizard.eipconfigchecker()
full_domain = self.field('provider_domain')
@@ -109,6 +106,10 @@ class ProviderInfoPage(ValidationPage):
domain, port = get_https_domain_and_port(full_domain)
_domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain)
+ netchecker = wizard.netchecker()
+ providercertchecker = wizard.providercertchecker()
+ eipconfigchecker = wizard.eipconfigchecker(domain=_domain)
+
update_signal.emit("head_sentinel", 0)
pause_for_user()
@@ -178,6 +179,8 @@ class ProviderInfoPage(ValidationPage):
update_signal.emit("Downloading provider info", 70)
try:
+ # XXX we already set _domain in the initialization
+ # so it should not be needed here.
eipconfigchecker.fetch_definition(domain=_domain)
wizard.set_providerconfig(
eipconfigchecker.defaultprovider.config)
diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/regvalidation.py
index e85c2ac6..6681b953 100644
--- a/src/leap/gui/firstrun/regvalidation.py
+++ b/src/leap/gui/firstrun/regvalidation.py
@@ -57,6 +57,7 @@ class RegisterUserValidationPage(ValidationPage):
wizard = self.wizard()
full_domain = self.field('provider_domain')
domain, port = get_https_domain_and_port(full_domain)
+ _domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain)
# FIXME #BUG 638 FIXME FIXME FIXME
verify = False # !!!!!!!!!!!!!!!!
@@ -77,7 +78,8 @@ class RegisterUserValidationPage(ValidationPage):
password = self.field(passwk)
credentials = username, password
- eipconfigchecker = wizard.eipconfigchecker()
+ eipconfigchecker = wizard.eipconfigchecker(domain=_domain)
+ #XXX change for _domain (sanitized)
pCertChecker = wizard.providercertchecker(
domain=full_domain)
@@ -174,6 +176,7 @@ class RegisterUserValidationPage(ValidationPage):
# 3) getting client certificate
##################################################
# XXX maybe only do this if we come from signup
+
step = "fetch_eipcert"
fetching_clientcert_msg = "Fetching eip certificate"
update_signal.emit(fetching_clientcert_msg, 80)
@@ -199,7 +202,7 @@ class RegisterUserValidationPage(ValidationPage):
pause_for_user()
# here we go! :)
- self.run_eip_checks_for_provider_and_connect(domain)
+ self.run_eip_checks_for_provider_and_connect(_domain)
def run_eip_checks_for_provider_and_connect(self, domain):
wizard = self.wizard()
@@ -208,6 +211,8 @@ class RegisterUserValidationPage(ValidationPage):
wizard,
'start_eipconnection_signal', None)
+ import pdb4qt; pdb4qt.set_trace()
+
if conductor:
conductor.set_provider_domain(domain)
conductor.run_checks()