summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2017-08-10 17:49:53 -0400
committerKali Kaneko <kali@leap.se>2017-08-11 14:21:56 -0400
commit763f88658a4e6d12557c7931f5435ebd35548ca7 (patch)
treea68466c2dcc2d495d11b702e73afef90a4dbcbb4 /src
parent63a68c4c976ec62cd0bd42bd1a365592201fb433 (diff)
[feature] add a new bitmask_chromium gui entrypoint
If chromium is installed in the system, there's no need to depend on qt5.
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/chrome/__init__.py0
-rw-r--r--src/leap/bitmask/chrome/chromeapp.py78
-rw-r--r--src/leap/bitmask/vpn/service.py3
3 files changed, 81 insertions, 0 deletions
diff --git a/src/leap/bitmask/chrome/__init__.py b/src/leap/bitmask/chrome/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/leap/bitmask/chrome/__init__.py
diff --git a/src/leap/bitmask/chrome/chromeapp.py b/src/leap/bitmask/chrome/chromeapp.py
new file mode 100644
index 00000000..b71fbdc7
--- /dev/null
+++ b/src/leap/bitmask/chrome/chromeapp.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+# chrome-app.py
+# Copyright (C) 2017 LEAP Encryption Acess Project
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+A minimal entrypoint to the Bitmask UI,
+that depends on chromium being installed in the system.
+"""
+
+import commands
+import os
+import sys
+import time
+
+from multiprocessing import Process
+
+from leap.bitmask.core.launcher import run_bitmaskd, pid
+from leap.common.config import get_path_prefix
+
+
+AUTHTOKEN_PATH = os.path.join(get_path_prefix(), 'leap', 'authtoken')
+
+
+def get_url():
+ url = "http://localhost:7070"
+ waiting = 20
+ while not os.path.isfile(AUTHTOKEN_PATH):
+ if waiting == 0:
+ # If we arrive here, something really messed up happened,
+ # because touching the token file is one of the first
+ # things the backend does, and this BrowserWindow
+ # should be called *right after* launching the backend.
+ raise NoAuthToken(
+ 'No authentication token found!')
+ time.sleep(0.1)
+ waiting -= 1
+ token = open(AUTHTOKEN_PATH).read().strip()
+ url += '#' + token
+ return url
+
+def delete_old_authtoken():
+ try:
+ os.remove(AUTHTOKEN_PATH)
+ except OSError:
+ pass
+
+
+def start_app():
+ if not commands.getoutput('which chromium'):
+ print ('[!] Cannot find chromium installed in the system!')
+ sys.exit(1)
+ delete_old_authtoken()
+ bitmaskd = Process(target=run_bitmaskd)
+ bitmaskd.start()
+
+ cmd = 'chromium -app=%s' % get_url()
+ commands.getoutput(cmd)
+
+
+class NoAuthToken(Exception):
+ pass
+
+
+if __name__ == "__main__":
+ start_app()
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index cfa00229..93080feb 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -197,6 +197,9 @@ class VPNService(HookableService):
bonafide = self.parent.getServiceNamed("bonafide")
config = yield bonafide.do_provider_read(provider, "eip")
+
+ # TODO - add gateway selection ability.
+ # First thing, we should port the TimezonSelector
remotes = [(gw["ip_address"], gw["capabilities"]["ports"][0])
for gw in config.gateways]
extra_flags = config.openvpn_configuration