diff options
author | Kali Kaneko <kali@leap.se> | 2017-08-11 03:21:35 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-08-11 14:21:58 -0400 |
commit | 4a7e29b6eae34f34016c9b409bd887c74b949ca4 (patch) | |
tree | a343c5de481f888c45c527401e13672ade0ab041 /src/leap/bitmask/vpn | |
parent | d64f3c22c132c5de0d759d1e76ff7ced054bfcaa (diff) |
[feature] add vpn list command
Diffstat (limited to 'src/leap/bitmask/vpn')
-rw-r--r-- | src/leap/bitmask/vpn/service.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py index 8bcee2e8..b0dcba86 100644 --- a/src/leap/bitmask/vpn/service.py +++ b/src/leap/bitmask/vpn/service.py @@ -190,14 +190,35 @@ class VPNService(HookableService): return {'uninstall': 'ok'} @defer.inlineCallbacks + def do_list(self): + bonafide = self.parent.getServiceNamed("bonafide") + _providers = yield bonafide.do_provider_list() + providers = [p['domain'] for p in _providers] + provider_dict = {} + for provider in providers: + try: + config = yield bonafide.do_provider_read(provider, 'eip') + except ValueError: + continue + locations = config.locations + info = tuple([ + ('[%s]' % locations[loc]['country_code'], + locations[loc]['name'], + '(UTC%s)' % locations[loc]['timezone']) + for loc in locations]) + provider_dict[provider] = info + defer.returnValue(provider_dict) + + + @defer.inlineCallbacks def _setup(self, provider): """Set up TunnelManager for a specified provider. :param provider: the provider to use, e.g. 'demo.bitmask.net' :type provider: str""" - bonafide = self.parent.getServiceNamed("bonafide") - config = yield bonafide.do_provider_read(provider, "eip") + bonafide = self.parent.getServiceNamed('bonafide') + config = yield bonafide.do_provider_read(provider, 'eip') sorted_gateways = GatewaySelector( config.gateways, config.locations).select_gateways() |