[tor-commits] [ooni-probe/develop] Add chained callbacks to handshake checking methods, and remove some unused

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


commit 1fa06bffa93632fb031ff690e69f50b0c2f65436
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Feb 28 04:41:01 2013 +0000

    Add chained callbacks to handshake checking methods, and remove some unused
    code from the end of the file.
---
 nettests/experimental/tls_handshake.py |   33 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py
index a21b357..d990a5b 100644
--- a/nettests/experimental/tls_handshake.py
+++ b/nettests/experimental/tls_handshake.py
@@ -599,24 +599,19 @@ class TLSHandshakeTest(nettest.NetTestCase):
             else:
                 defer.returnValue(connection)
 
-        addr, port = self.input
-        connection = defer.maybeDeferred(makeConnection, addr, port)
-        connection.addCallback(doHandshake)
-        connection.addErrback(log.err)
-        connection.addCallback(handshakeSucceeded)
-        connection.addErrback(handshakeFailed)
+        connection = deferMakeConnection(self.input)
+        connection.addCallbacks(connectionSucceeded, connectionFailed,
+                                callbackArgs=[self.input, self.timeout],
+                                errbackArgs=[self.input])
 
-        return connection
+        handshake = defer.Deferred()
+        handshake.addCallback(doHandshake)
+        handshake.addCallbacks(handshakeSucceeded, handshakeFailed,
+                               errbackArgs=[self.input])
 
-## XXX clean me up
-## old function from anonymous contribution: (saved mostly for reference of the
-## success string)
-##
-#def checkBridgeConnection(host, port)
-#  cipher_arg = ":".join(ciphers)
-#  cmd  = ["openssl", "s_client", "-connect", "%s:%s" % (host,port)]
-#  cmd += ["-cipher", cipher_arg]
-#  proc = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE,stdin=PIPE)
-#  out, error = proc.communicate()
-#  success = "Cipher is DHE-RSA-AES256-SHA" in out
-#  return success
+        connection.chainDeferred(handshake)
+        connection.addCallbacks(connectionShutdown, defer.passthru,
+                                callbackArgs=[self.input])
+        connection.addBoth(log.exception)
+
+        return connection





More information about the tor-commits mailing list