From 4e3b2f09f0e5fba35aef3edf8ad2b23c64a5d995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Wed, 13 Mar 2013 15:46:50 -0300 Subject: Use a unix socket every time for now Will need a special case for windows --- src/leap/gui/mainwindow.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 6aaf0a38..c2c37485 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -20,7 +20,7 @@ Main window for the leap client """ import os import logging -import random +import tempfile import keyring from PySide import QtCore, QtGui @@ -603,12 +603,27 @@ class MainWindow(QtGui.QMainWindow): self._systray.setIcon(self.LOGGED_IN_ICON) self._download_eip_config() + def _get_socket_host(self): + """ + Returns the socket and port to be used for VPN + + @rtype: tuple (str, str) (host, port) + """ + + # TODO: make this properly multiplatform + host = os.path.join(tempfile.mkdtemp(prefix="leap-tmp"), + 'openvpn.socket') + port = "unix" + + return host, port + def _start_eip(self): try: + host, port = self._get_socket_host() self._vpn.start(eipconfig=self._eip_config, providerconfig=self._provider_config, - socket_host="localhost", - socket_port=str(random.randint(1000, 9999))) + socket_host=host, + socket_port=port) self._vpn_systray.setVisible(True) self.ui.btnEipStartStop.setText(self.tr("Stop EIP")) self.ui.btnEipStartStop.disconnect(self) -- cgit v1.2.3