summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/changelog.rst1
-rw-r--r--setup.py5
-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
5 files changed, 86 insertions, 1 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst
index cf38716..c9b9445 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -24,6 +24,7 @@ Features
- Port Pixelated UA integration from legacy bitmask
- Add Pixelated Button to the UI
- Add ability to ssh into the bitmask daemon for debug
+- New ``bitmask_chromium`` gui: launches Bitmask UI as a standalone chromium app if chromium is installed in your system.
Bugfixes
~~~~~~~~
diff --git a/setup.py b/setup.py
index 919a91e..e955ccd 100644
--- a/setup.py
+++ b/setup.py
@@ -66,6 +66,7 @@ DOWNLOAD_URL = DOWNLOAD_BASE % VERSION
# Entry points
gui_launcher = 'bitmask=leap.bitmask.gui.app:start_app'
+chrome_launcher = 'bitmask_chromium=leap.bitmask.chrome.chromeapp:start_app'
bitmask_cli = 'bitmaskctl=leap.bitmask.cli.bitmask_cli:main'
bitmask_helpers = 'bitmask_helpers=leap.bitmask.vpn.helpers:main'
bitmaskd = 'bitmaskd=leap.bitmask.core.launcher:run_bitmaskd'
@@ -94,7 +95,9 @@ setup(
zip_safe=False,
entry_points={
'console_scripts': [
- gui_launcher, bitmask_cli,
+ gui_launcher,
+ chrome_launcher,
+ bitmask_cli,
bitmaskd,
bitmask_helpers]
},
diff --git a/src/leap/bitmask/chrome/__init__.py b/src/leap/bitmask/chrome/__init__.py
new file mode 100644
index 0000000..e69de29
--- /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 0000000..b71fbdc
--- /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 cfa0022..93080fe 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