commit 86f914d18a4e6d76365e3ec35d50f35267865279
Author: Arturo Filastò <art(a)fuffa.org>
Date: Wed Nov 21 11:23:37 2012 +0100
Rename sockport and sockhost parameters in txagentwithsocks to socksport and sockshost
---
ooni/lib/txagentwithsocks.py | 21 ++++++++++++---------
ooni/reporter.py | 6 ++++--
ooni/templates/httpt.py | 8 ++++----
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/ooni/lib/txagentwithsocks.py b/ooni/lib/txagentwithsocks.py
index a1f7f48..fc1c17c 100644
--- a/ooni/lib/txagentwithsocks.py
+++ b/ooni/lib/txagentwithsocks.py
@@ -98,12 +98,12 @@ class SOCKSv5ClientFactory(_WrappingFactory):
class SOCKS5ClientEndpoint(object):
implements(interfaces.IStreamClientEndpoint)
- def __init__(self, reactor, sockhost, sockport,
+ def __init__(self, reactor, sockshost, socksport,
host, port, timeout=30, bindAddress=None):
self._reactor = reactor
- self._sockhost = sockhost
- self._sockport = sockport
+ self._sockshost = sockshost
+ self._socksport = socksport
self._host = host
self._port = port
self._timeout = timeout
@@ -113,7 +113,7 @@ class SOCKS5ClientEndpoint(object):
try:
wf = SOCKSv5ClientFactory(protocolFactory, self._host, self._port)
self._reactor.connectTCP(
- self._sockhost, self._sockport, wf,
+ self._sockshost, self._socksport, wf,
timeout=self._timeout, bindAddress=self._bindAddress)
return wf._onConnection
except:
@@ -204,7 +204,7 @@ class Agent(client.Agent):
def __init__(self, reactor,
contextFactory=client.WebClientContextFactory(),
connectTimeout=None, bindAddress=None,
- pool=None, sockhost=None, sockport=None):
+ pool=None, sockshost=None, socksport=None):
if pool is None:
pool = HTTPConnectionPool(reactor, False)
self._reactor = reactor
@@ -212,8 +212,8 @@ class Agent(client.Agent):
self._contextFactory = contextFactory
self._connectTimeout = connectTimeout
self._bindAddress = bindAddress
- self._sockhost = sockhost
- self._sockport = sockport
+ self._sockshost = sockshost
+ self._socksport = socksport
def _getEndpoint(self, scheme, host, port):
kwargs = {}
@@ -223,8 +223,11 @@ class Agent(client.Agent):
if scheme == 'http':
return TCP4ClientEndpoint(self._reactor, host, port, **kwargs)
elif scheme == 'shttp':
- return SOCKS5ClientEndpoint(self._reactor, self._sockhost,
- self._sockport, host, port, **kwargs)
+ return SOCKS5ClientEndpoint(self._reactor, self._sockshost,
+ self._socksport, host, port, **kwargs)
+ elif scheme == 'httpo':
+ return SOCKS5ClientEndpoint(self._reactor, self._sockshost,
+ self._socksport, host, port, **kwargs)
elif scheme == 'https':
return SSL4ClientEndpoint(self._reactor, host, port,
self._wrapContextFactory(host, port),
diff --git a/ooni/reporter.py b/ooni/reporter.py
index 05ea94a..5006a21 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -185,9 +185,11 @@ class OONIBTestDetailsLookupFailed(Exception):
class OONIBReporter(OReporter):
def __init__(self, backend_url):
- from twisted.web.client import Agent
+ from ooni.lib.txagentwithsocks import Agent
from twisted.internet import reactor
- self.agent = Agent(reactor)
+
+ self.agent = Agent(reactor, sockshost="127.0.0.1",
+ socksport=config.advanced.socksport)
self.backend_url = backend_url
@defer.inlineCallbacks
diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 7caab39..c62ea4d 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -59,16 +59,16 @@ class HTTPTest(NetTestCase):
log.err("Warning! pyOpenSSL is not installed. https websites will"
"not work")
- self.control_agent = Agent(reactor, sockhost="127.0.0.1",
- sockport=config.advanced.tor_socksport)
+ self.control_agent = Agent(reactor, sockshost="127.0.0.1",
+ socksport=config.advanced.tor_socksport)
sockshost, socksport = (None, None)
if self.localOptions['socksproxy']:
sockshost, socksport = self.localOptions['socksproxy'].split(':')
socksport = int(socksport)
- self.agent = Agent(reactor, sockhost=sockshost,
- sockport=socksport)
+ self.agent = Agent(reactor, sockshost=sockshost,
+ socksport=socksport)
if self.followRedirects:
try: