summaryrefslogtreecommitdiff
path: root/src/leap/eip/conductor.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-03 07:32:47 +0900
committerkali <kali@leap.se>2012-08-03 07:36:58 +0900
commitb9c9b5536f9d1648a196e741cdf4570f64c3fb11 (patch)
treebea7b258b22910995fb5025ed7625d01884dceea /src/leap/eip/conductor.py
parent65db011c13aa6bf03867cc0e579f191cbf611ef6 (diff)
build default invocation command + options
if not found in config file. fix #182 and #356
Diffstat (limited to 'src/leap/eip/conductor.py')
-rw-r--r--src/leap/eip/conductor.py26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/leap/eip/conductor.py b/src/leap/eip/conductor.py
index b1683e7d..bf7f0fb2 100644
--- a/src/leap/eip/conductor.py
+++ b/src/leap/eip/conductor.py
@@ -8,7 +8,7 @@ import logging
from leap.util.coroutines import spawn_and_watch_process
-from leap.eip.config import get_config, get_vpn_stdout_mockup
+from leap.eip.config import get_config, build_ovpn_command
from leap.eip.vpnwatcher import EIPConnectionStatus, status_watcher
from leap.eip.vpnmanager import OpenVPNManager, ConnectionRefusedError
@@ -82,21 +82,13 @@ to be triggered for each one of them.
self.proto = None
self.autostart = True
-
self._get_or_create_config()
- def _set_command_mockup(self):
- """
- sets command and args for a command mockup
- that just mimics the output from the real thing
- """
- command, args = get_vpn_stdout_mockup()
- self.command, self.args = command, args
-
def _get_or_create_config(self):
"""
retrieves the config options from defaults or
home file, or config file passed in command line.
+ populates command and args to be passed to subprocess.
"""
#print('get or create config')
config = get_config(config_file=self.config_file)
@@ -105,12 +97,6 @@ to be triggered for each one of them.
if config.has_option('openvpn', 'command'):
commandline = config.get('openvpn', 'command')
- #XXX remove mockup from here.
- #it was just for testing early.
- if commandline == "mockup":
- self._set_command_mockup()
- return
-
command_split = commandline.split(' ')
command = command_split[0]
if len(command_split) > 1:
@@ -122,11 +108,14 @@ to be triggered for each one of them.
self.command = command
self.args = args
else:
- self._set_command_mockup()
+ # no command in config, we build it up.
+ # XXX check also for command-line --command flag
+ command, args = build_ovpn_command(config)
+ self.command = command
+ self.args = args
if config.has_option('openvpn', 'autostart'):
autostart = config.getboolean('openvpn', 'autostart')
- print('autostart = %s' % autostart)
self.autostart = autostart
else:
if config.has_option('DEFAULT', 'autostart'):
@@ -211,7 +200,6 @@ class EIPConductor(OpenVPNConnection):
self._disconnect()
self.status.change_to(self.status.DISCONNECTED)
-
def poll_connection_state(self):
"""
"""