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

[tor-commits] [ooni-probe/master] Proper fix for issue reported by @anadahz in #401



commit 11511563659b4d3a18aa9e2c1a189d3cf1139155
Author: Simone Basso <bassosimone@xxxxxxxxx>
Date:   Tue Nov 17 15:44:03 2015 +0100

    Proper fix for issue reported by @anadahz in #401
---
 ooni/utils/trueheaders.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/ooni/utils/trueheaders.py b/ooni/utils/trueheaders.py
index ac73970..149b440 100644
--- a/ooni/utils/trueheaders.py
+++ b/ooni/utils/trueheaders.py
@@ -20,6 +20,9 @@ SOCKS5ClientFactory.noisy = False
 
 from ooni.utils import log
 
+import twisted
+from twisted.python.versions import Version
+
 
 class TrueHeaders(http_headers.Headers):
     def __init__(self, rawHeaders=None):
@@ -160,7 +163,19 @@ class TrueHeadersAgent(client.Agent):
         self._pool = HTTPConnectionPool(reactor, False)
 
 
+_twisted_15_0 = Version('twisted', 15, 0, 0)
+
+
 class TrueHeadersSOCKS5Agent(SOCKS5Agent):
     def __init__(self, *args, **kw):
         super(TrueHeadersSOCKS5Agent, self).__init__(*args, **kw)
-        self._pool = HTTPConnectionPool(reactor, False)
+        pool = HTTPConnectionPool(reactor, False)
+        #
+        # With Twisted > 15.0 txsocksx wraps the twisted agent using a
+        # wrapper class, hence we must set the _pool attribute in the
+        # inner class rather than into its external wrapper.
+        #
+        if twisted.version >= _twisted_15_0:
+            self._wrappedAgent._pool = pool
+        else:
+            self._pool = pool



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