[Pkg-privacy-commits] [onionshare] 125/256: Started to implement Bundled Tor connection settings

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit da225ed7d1871ae9f4173bf2ccd9d1b7bdf88a83
Author: Micah Lee <micah at micahflee.com>
Date:   Sat Apr 8 18:10:17 2017 -0700

    Started to implement Bundled Tor connection settings
---
 onionshare/__init__.py            |  7 ++++---
 onionshare/onion.py               | 15 +++++++++++++++
 onionshare_gui/settings_dialog.py |  4 ++--
 share/locale/en.json              |  1 +
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/onionshare/__init__.py b/onionshare/__init__.py
index 58f6a1c..e0608b6 100644
--- a/onionshare/__init__.py
+++ b/onionshare/__init__.py
@@ -20,7 +20,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os, sys, time, argparse, shutil, socket, threading
 
-from . import strings, helpers, web, onion
+from . import strings, helpers, web
+from .onion import *
 
 class OnionShare(object):
     """
@@ -84,7 +85,7 @@ class OnionShare(object):
             return
 
         if not self.onion:
-            self.onion = onion.Onion(self.stealth)
+            self.onion = Onion(self.stealth)
 
         self.onion_host = self.onion.start(self.port)
 
@@ -155,7 +156,7 @@ def main(cwd=None):
         app = OnionShare(debug, local_only, stay_open, transparent_torification, stealth)
         app.choose_port()
         app.start_onion_service()
-    except (onion.TorTooOld, onion.TorErrorInvalidSetting, onion.TorErrorAutomatic, onion.TorErrorSocketPort, onion.TorErrorSocketFile, onion.TorErrorMissingPassword, onion.TorErrorUnreadableCookieFile, onion.TorErrorAuthError, onion.TorErrorProtocolError) as e:
+    except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported) as e:
         sys.exit(e.args[0])
     except KeyboardInterrupt:
         print("")
diff --git a/onionshare/onion.py b/onionshare/onion.py
index bb2bca7..ccfdd4b 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -87,6 +87,12 @@ class TorTooOld(Exception):
     """
     pass
 
+class BundledTorNotSupported(Exception):
+    """
+    This exception is raised if onionshare is set to use the bundled Tor binary,
+    but it's not supported on that platform, or in dev mode.
+    """
+
 class Onion(object):
     """
     Onion is an abstraction layer for connecting to the Tor control port and
@@ -107,6 +113,15 @@ class Onion(object):
         # Try to connect to Tor
         self.c = None
 
+        if self.settings.get('connection_type') == 'bundled':
+            dev_mode = getattr(sys, 'onionshare_dev_mode', False)
+            p = platform.system()
+
+            if (p != 'Windows' and p != 'Darwin') or dev_mode:
+                raise BundledTorNotSupported(strings._('settings_error_bundled_tor_not_supported'))
+
+            # TODO: actually implement bundled Tor
+
         if self.settings.get('connection_type') == 'automatic':
             # Automatically try to guess the right way to connect to Tor Browser
             p = platform.system()
diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py
index 3a41dfd..ee34088 100644
--- a/onionshare_gui/settings_dialog.py
+++ b/onionshare_gui/settings_dialog.py
@@ -22,7 +22,7 @@ import sys, platform
 
 from onionshare import strings
 from onionshare.settings import Settings
-from onionshare.onion import Onion, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError
+from onionshare.onion import *
 
 from .alert import Alert
 
@@ -290,7 +290,7 @@ class SettingsDialog(QtWidgets.QDialog):
             # If an exception hasn't been raised yet, the Tor settings work
             Alert(strings._('settings_test_success', True).format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth))
 
-        except (TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError) as e:
+        except (TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported) as e:
             Alert(e.args[0], QtWidgets.QMessageBox.Warning)
 
     def save_clicked(self):
diff --git a/share/locale/en.json b/share/locale/en.json
index 9f192a4..29b2bad 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -85,6 +85,7 @@
     "settings_error_auth": "Connected to {}:{}, but can't authenticate. Maybe this isn't a Tor controller?",
     "settings_error_missing_password": "Connected to Tor controller, but it requires a password to authenticate.",
     "settings_error_unreadable_cookie_file": "Connected to Tor controller, but can't authenticate because your password may be wrong, and your user doesn't have permission to read the cookie file.",
+    "settings_error_bundled_tor_not_supported": "Bundled Tor is only supported in Windows and macOS. It's not supported when not using developer mode or the command line interface.",
     "settings_test_success": "Congratulations, OnionShare can connect to the Tor controller.\n\nTor version: {}\nSupports ephemeral onion services: {}\nSupports stealth onion services: {}",
     "error_tor_protocol_error": "Error talking to the Tor controller.\nIf you're using Whonix, check out https://www.whonix.org/wiki/onionshare to make OnionShare work."
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list