[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] More detailed error handling for SOCKS



commit 9e895b646998f4a98611e9a24c1b15d11b666ec3
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Mon Dec 24 03:30:49 2012 +0100

    More detailed error handling for SOCKS
---
 ooni/nettest.py |   57 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index e67b1ba..06ed4cb 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -17,6 +17,13 @@ from twisted.web._newclient import ResponseNeverReceived
 from ooni.utils import log
 
 from txsocksx.errors import SOCKSError
+from txsocksx.errors import MethodsNotAcceptedError, AddressNotSupported
+from txsocksx.errors import ConnectionError, NetworkUnreachable
+from txsocksx.errors import ConnectionLostEarly, ConnectionNotAllowed
+from txsocksx.errors import NoAcceptableMethods, ServerFailure
+from txsocksx.errors import HostUnreachable, ConnectionRefused
+from txsocksx.errors import TTLExpired, CommandNotSupported
+
 
 from socket import gaierror
 
@@ -26,9 +33,14 @@ def handleAllFailures(failure):
     failureToString function and we return the the string that represents the
     failure.
     """
-    failure.trap(ConnectionRefusedError, gaierror, SOCKSError,
-        DNSLookupError, TCPTimedOutError, ResponseNeverReceived,
-        DeferTimeoutError, GenericTimeoutError)
+    failure.trap(ConnectionRefusedError, gaierror, DNSLookupError,
+            TCPTimedOutError, ResponseNeverReceived, DeferTimeoutError,
+            GenericTimeoutError,
+            SOCKSError, MethodsNotAcceptedError, AddressNotSupported,
+            ConnectionError, NetworkUnreachable, ConnectionLostEarly,
+            ConnectionNotAllowed, NoAcceptableMethods, ServerFailure,
+            HostUnreachable, ConnectionRefused, TTLExpired, CommandNotSupported)
+
     return failureToString(failure)
 
 def failureToString(failure):
@@ -53,10 +65,6 @@ def failureToString(failure):
         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'
-
     elif isinstance(failure.value, DNSLookupError):
         log.err("DNS lookup failure")
         string = 'dns_lookup_error'
@@ -77,6 +85,41 @@ def failureToString(failure):
         log.err("Time Out Error")
         string = 'generic_timeout_error'
 
+    elif isinstance(failure.value, ServerFailure):
+        log.err("SOCKS error: ServerFailure")
+        string = 'socks_server_failure'
+
+    elif isinstance(failure.value, ConnectionNotAllowed):
+        log.err("SOCKS error: ConnectionNotAllowed")
+        string = 'socks_connection_not_allowed'
+
+    elif isinstance(failure.value, NetworkUnreachable):
+        log.err("SOCKS error: NetworkUnreachable")
+        string = 'socks_network_unreachable'
+
+    elif isinstance(failure.value, HostUnreachable):
+        log.err("SOCKS error: HostUnreachable")
+        string = 'socks_host_unreachable'
+
+    elif isinstance(failure.value, ConnectionRefused):
+        log.err("SOCKS error: ConnectionRefused")
+        string = 'socks_connection_refused'
+
+    elif isinstance(failure.value, TTLExpired):
+        log.err("SOCKS error: TTLExpired")
+        string = 'socks_ttl_expired'
+
+    elif isinstance(failure.value, CommandNotSupported):
+        log.err("SOCKS error: CommandNotSupported")
+        string = 'socks_command_not_supported'
+
+    elif isinstance(failure.value, AddressNotSupported):
+        log.err("SOCKS error: AddressNotSupported")
+        string = 'socks_address_not_supported'
+    elif isinstance(failure.value, SOCKSError):
+        log.err("Generic SOCKS error")
+        string = 'socks_error'
+
     else:
         log.err("Unknown failure type: %s" % type(failure))
         string = 'unknown_failure %s' % str(failure.value)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits