summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/eip/vpnlauncher.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-03-04 18:03:47 -0300
committerRuben Pollan <meskio@sindominio.net>2015-03-30 22:42:52 +0200
commit3cb7948dafe3a9c9a65dcdbd1da1d5405e1ef459 (patch)
treeddf0f171313e13dd8a776a5119a88ecccd187ec1 /src/leap/bitmask/services/eip/vpnlauncher.py
parent6e8639a480d63acd5c8bc044a8b1ca907c325233 (diff)
[bug] use ports specified in eip-service.json
Replace the hardcoded port '1194' for the port specified in eip-service.json. Choose the best port to use according which one is enabled in the eip-service.json file Resolves: #6541
Diffstat (limited to 'src/leap/bitmask/services/eip/vpnlauncher.py')
-rw-r--r--src/leap/bitmask/services/eip/vpnlauncher.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/leap/bitmask/services/eip/vpnlauncher.py b/src/leap/bitmask/services/eip/vpnlauncher.py
index 72e19413..7793d624 100644
--- a/src/leap/bitmask/services/eip/vpnlauncher.py
+++ b/src/leap/bitmask/services/eip/vpnlauncher.py
@@ -106,12 +106,15 @@ class VPNLauncher(object):
UP_SCRIPT = None
DOWN_SCRIPT = None
+ PREFERRED_PORTS = ("443", "80", "53", "1194")
+
@classmethod
@abstractmethod
def get_gateways(kls, eipconfig, providerconfig):
"""
- Return the selected gateways for a given provider, looking at the EIP
- config file.
+ Return a list with the selected gateways for a given provider, looking
+ at the EIP config file.
+ Each item of the list is a tuple containing (gateway, port).
:param eipconfig: eip configuration object
:type eipconfig: EIPConfig
@@ -122,21 +125,37 @@ class VPNLauncher(object):
:rtype: list
"""
gateways = []
+
settings = Settings()
domain = providerconfig.get_domain()
gateway_conf = settings.get_selected_gateway(domain)
gateway_selector = VPNGatewaySelector(eipconfig)
if gateway_conf == GATEWAY_AUTOMATIC:
- gateways = gateway_selector.get_gateways()
+ gws = gateway_selector.get_gateways()
else:
- gateways = [gateway_conf]
+ gws = [gateway_conf]
- if not gateways:
+ if not gws:
logger.error('No gateway was found!')
raise VPNLauncherException('No gateway was found!')
- logger.debug("Using gateways ips: {0}".format(', '.join(gateways)))
+ for idx, gw in enumerate(gws):
+ ports = eipconfig.get_gateway_ports(idx)
+
+ the_port = "1194" # default port
+
+ # pick the port preferring this order:
+ for port in kls.PREFERRED_PORTS:
+ if port in ports:
+ the_port = port
+ break
+ else:
+ continue
+
+ gateways.append((gw, the_port))
+
+ logger.debug("Using gateways (ip, port): {0!r}".format(gateways))
return gateways
@classmethod
@@ -194,8 +213,8 @@ class VPNLauncher(object):
gateways = kls.get_gateways(eipconfig, providerconfig)
- for gw in gateways:
- args += ['--remote', gw, '1194', 'udp']
+ for ip, port in gateways:
+ args += ['--remote', ip, port, 'udp']
args += [
'--client',