diff options
author | kali <kali@leap.se> | 2012-09-19 05:52:16 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-09-19 05:52:16 +0900 |
commit | 6a9523b0e83aca75bbfde5a8939ee612c5a78f9a (patch) | |
tree | 3e02cc37dc9174aee49227f2f9942d5ae1b35a6b /src/leap/eip | |
parent | 68b1a4a987b85540d2f13cfc800cbdf5efc27805 (diff) |
openvpn options come from eip.json
Diffstat (limited to 'src/leap/eip')
-rw-r--r-- | src/leap/eip/config.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py index c3e830dd..e5fcd164 100644 --- a/src/leap/eip/config.py +++ b/src/leap/eip/config.py @@ -21,7 +21,11 @@ class EIPConfig(baseconfig.JSONLeapConfig): spec = eipspecs.eipconfig_spec def _get_slug(self): - return baseconfig.get_config_file('eip.json') + dppath = baseconfig.get_default_provider_path() + eipjsonpath = baseconfig.get_config_file( + 'eip-service.json', + folder=dppath) + return eipjsonpath def _set_slug(self, *args, **kwargs): raise AttributeError("you cannot set slug") @@ -51,6 +55,25 @@ def get_socket_path(): return socket_path +def get_eip_gateway(): + """ + return the first host in the list of hosts + under gateways list + """ + eipconfig = EIPConfig() + eipconfig.load() + conf = eipconfig.get_config() + gateways = conf.get('gateways', None) + if len(gateways) > 0: + # we just pick first + gw = gateways[0] + hosts = gw['hosts'] + if len(hosts) > 0: + return hosts[0] + else: + return "testprovider.example.org" + + def build_ovpn_options(daemon=False, socket_path=None, **kwargs): """ build a list of options @@ -87,9 +110,10 @@ def build_ovpn_options(daemon=False, socket_path=None, **kwargs): opts.append("%s" % verbosity) # remote - # XXX get remote from eip.json opts.append('--remote') - opts.append('testprovider.example.org') + gw = get_eip_gateway() + logger.debug('setting eip gateway to %s', gw) + opts.append(str(gw)) opts.append('1194') opts.append('udp') @@ -140,6 +164,7 @@ def build_ovpn_options(daemon=False, socket_path=None, **kwargs): #if daemon is True: #opts.append('--daemon') + logger.debug('vpn options: %s', opts) return opts |