[tor-commits] [ooni-probe/master] Catch socket.gaierror

art at torproject.org art at torproject.org
Fri Dec 7 09:34:24 UTC 2012


commit 47891d7bdfda807d02cf7b982fa92aa4a888edaa
Author: aagbsn <aagbsn at extc.org>
Date:   Fri Dec 7 03:31:59 2012 +0000

    Catch socket.gaierror
    
    Import SOCKSError, ResponseNeverReceived
    Add error logging for unknown failure types
    Log entire failure instance
    Try to catch more details about errors
---
 ooni/nettest.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index 22a35c9..fcc945a 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -8,8 +8,13 @@ from twisted.internet import defer, utils
 from twisted.python import usage
 
 from twisted.internet.error import ConnectionRefusedError, DNSLookupError, TCPTimedOutError
+from twisted.internet.defer import TimeoutError
+from twisted.web._newclient import ResponseNeverReceived
 
 from ooni.utils import log
+from ooni.utils.txagentwithsocks import SOCKSError
+
+from socket import gaierror
 
 def failureToString(failure):
     """
@@ -24,10 +29,15 @@ def failureToString(failure):
 
         A string representing the HTTP response error message.
     """
+    string = None
     if isinstance(failure.value, ConnectionRefusedError):
         log.err("Connection refused. The backend may be down")
         string = 'connection_refused_error'
 
+    elif isinstance(failure.value, gaierror):
+        log.err("Address family for hostname not supported")
+        string = 'address_family_not_supported_error'
+
     elif isinstance(failure.value, SOCKSError):
         log.err("Sock error. The SOCKS proxy may be down")
         string = 'socks_error'
@@ -43,6 +53,13 @@ def failureToString(failure):
     elif isinstance(failure.value, ResponseNeverReceived):
         log.err("Response Never Received")
         string = 'response_never_received'
+
+    elif isinstance(failure.value, TimeoutError):
+        log.err("Deferred Timed Out Error")
+        string = 'deferred_timed_out_error'
+
+    else:
+        log.err("Unknown failure type: %s" % type(failure))
     return string
 
 class NoPostProcessor(Exception):





More information about the tor-commits mailing list