[Pkg-privacy-commits] [onionshare] 193/256: Catch errors that occur when connection_type is bundled_tor, but the tor process closes before it can connect

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:39 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 d3a7eef95c1addc72aac973d491e5b22402b5736
Author: Micah Lee <micah at micahflee.com>
Date:   Wed May 17 12:00:42 2017 -0700

    Catch errors that occur when connection_type is bundled_tor, but the tor process closes before it can connect
---
 onionshare/onion.py  | 21 +++++++++++++++------
 share/locale/en.json |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/onionshare/onion.py b/onionshare/onion.py
index ed685dc..14d9cff 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -105,6 +105,12 @@ class BundledTorCanceled(Exception):
     and the user cancels connecting to Tor
     """
 
+class BundledTorBroken(Exception):
+    """
+    This exception is raised if onionshare is set to use the bundled Tor binary,
+    but the process seems to fail to run.
+    """
+
 class Onion(object):
     """
     Onion is an abstraction layer for connecting to the Tor control port and
@@ -202,12 +208,15 @@ class Onion(object):
             time.sleep(0.2)
 
             # Connect to the controller
-            if self.system == 'Windows':
-                self.c = Controller.from_port(port=self.tor_control_port)
-                self.c.authenticate()
-            else:
-                self.c = Controller.from_socket_file(path=self.tor_control_socket)
-                self.c.authenticate()
+            try:
+                if self.system == 'Windows':
+                    self.c = Controller.from_port(port=self.tor_control_port)
+                    self.c.authenticate()
+                else:
+                    self.c = Controller.from_socket_file(path=self.tor_control_socket)
+                    self.c.authenticate()
+            except Exception as e:
+                raise BundledTorBroken(strings._('settings_error_bundled_tor_broken', True).format(e.args[0]))
 
             while True:
                 try:
diff --git a/share/locale/en.json b/share/locale/en.json
index 9a9a0e2..79e5277 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -91,6 +91,7 @@
     "settings_error_bundled_tor_not_supported": "Bundled Tor is not supported when not using developer mode in Windows or macOS.",
     "settings_error_bundled_tor_timeout": "Connecting to Tor is taking too long. Maybe your computer is offline, or your clock isn't accurate.",
     "settings_error_bundled_tor_canceled": "The Tor process closed before it could finish connecting.",
+    "settings_error_bundled_tor_broken": "Something is wrong with OnionShare connecting to Tor in the background:\n{}",
     "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.",
     "connecting_to_tor": "Connecting to the Tor network",

-- 
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