[tor-commits] [ooni-probe/master] Replace txagentwithsocks in httpt template
art at torproject.org
art at torproject.org
Wed Nov 6 09:12:44 UTC 2013
commit 30c556c3a06fcbfd3823bef90387f8b023a2998a
Author: aagbsn <aagbsn at extc.org>
Date: Mon Sep 16 10:40:26 2013 +0200
Replace txagentwithsocks in httpt template
---
ooni/templates/httpt.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 5542a85..79ac475 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -8,8 +8,10 @@ from twisted.internet.ssl import ClientContextFactory
from twisted.internet import reactor
from twisted.internet.error import ConnectionRefusedError, DNSLookupError, TCPTimedOutError
-
+from twisted.internet.endpoints import TCP4ClientEndpoint
from twisted.web._newclient import Request, Response, ResponseNeverReceived
+from twisted.web.client import Agent
+from txsocksx.http import SOCKS5Agent
from ooni.nettest import NetTestCase
from ooni.utils import log
@@ -17,7 +19,7 @@ from ooni.settings import config
from ooni.utils.net import BodyReceiver, StringProducer, userAgents
-from ooni.utils.txagentwithsocks import Agent, TrueHeaders
+from ooni.utils.txagentwithsocks import TrueHeaders
from ooni.errors import handleAllFailures
@@ -62,8 +64,9 @@ class HTTPTest(NetTestCase):
log.err("Warning! pyOpenSSL is not installed. https websites will "
"not work")
- self.control_agent = Agent(reactor, sockshost="127.0.0.1",
- socksport=config.tor.socks_port)
+ self.control_agent = SOCKS5Agent(reactor,
+ proxyEndpoint=TCP4ClientEndpoint(reactor, '127.0.0.1',
+ config.tor.socks_port))
self.report['socksproxy'] = None
sockshost, socksport = (None, None)
@@ -74,8 +77,12 @@ class HTTPTest(NetTestCase):
except ValueError:
raise InvalidSocksProxyOption
socksport = int(socksport)
-
- self.agent = Agent(reactor, sockshost=sockshost, socksport=socksport)
+ self.agent = SOCKS5Agent(reactor,
+ proxyEndpoint=TCP4ClientEndpoint(reactor, sockshost,
+ socksport))
+ else:
+ #XXX: pool?
+ self.agent = Agent(reactor)
self.report['agent'] = 'agent'
@@ -270,14 +277,12 @@ class HTTPTest(NetTestCase):
# configured socks proxy
if use_tor:
log.debug("Using Tor for the request to %s" % url)
- url = 's'+url
agent = self.control_agent
else:
agent = self.agent
if self.localOptions['socksproxy']:
log.debug("Using SOCKS proxy %s for request" % (self.localOptions['socksproxy']))
- url = 's'+url
log.debug("Performing request %s %s %s" % (url, method, headers))
More information about the tor-commits
mailing list