[tor-commits] [ooni-probe/develop] Fix method connectionFailed to handle socket timeouts.

isis at torproject.org isis at torproject.org
Thu Jun 6 16:41:37 UTC 2013


commit 61cea5561d9a22dd9009331ca16b7506a3c24d7f
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Feb 28 17:42:31 2013 +0000

    Fix method connectionFailed to handle socket timeouts.
---
 nettests/experimental/tls_handshake.py |   33 +++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py
index 4c42017..610cdff 100644
--- a/nettests/experimental/tls_handshake.py
+++ b/nettests/experimental/tls_handshake.py
@@ -292,22 +292,29 @@ class TLSHandshakeTest(nettest.NetTestCase):
                          specifying the host port, i.e. ('1.1.1.1', 443)
             """
             addr, port = host
-            if isinstance(connection, IOError):
-                ## On some *nix distros, /dev/random is 0600 root:root and we get
-                ## a permissions error when trying to read
-                if connection.message.find("[Errno 13]"):
-                    raise NotRootError(
-                        "%s" % connection.message.split("[Errno 13]", 1)[1])
-
-            if isinstance(connection, socket_error):
-                if connection.message.find("[Errno 101]"):
-                    raise HostUnreachableError(
-                        "Host unreachable: %s:%s" % (addr, port))
-
-            log.err(connection)
+
+            if not isinstance(connection, SSL.Connection):
+                if isinstance(connection, IOError):
+                    ## On some *nix distros, /dev/random is 0600 root:root and
+                    ## we get a permissions error when trying to read
+                    if connection.message.find("[Errno 13]"):
+                        raise NotRootError(
+                            "%s" % connection.message.split("[Errno 13]", 1)[1])
+                elif isinstance(connection, socket_error):
+                    if connection.message.find("[Errno 101]"):
+                        raise HostUnreachableError(
+                            "Host unreachable: %s:%s" % (addr, port))
+                elif isinstance(connection, Exception):
+                    log.debug("connectionFailed: got Exception:")
+                    log.err("Connection failed with reason: %s"
+                            % connection.message)
+                else:
+                    log.err("Connection failed with reason: %s" % str(connection))
+
             self.report['host'] = addr
             self.report['port'] = port
             self.report['state'] = 'CONNECTION_FAILED'
+
             return connection
 
         def connectionSucceeded(connection, host, timeout):





More information about the tor-commits mailing list