[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Start adding support for using txsocksx inside of oonibclient.
commit 4e9dd2911274054b4fd467bfac53798e8d0e1987
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Mon Sep 16 13:16:12 2013 +0200
Start adding support for using txsocksx inside of oonibclient.
There is some badness happening because we use the httpo (HTTP over Tor Hidden
Service) as the scheme name.
---
.../manipulation/http_header_field_manipulation.py | 2 +-
ooni/oonibclient.py | 10 ++++++++--
ooni/reporter.py | 20 +++++++++++++-------
ooni/templates/httpt.py | 2 +-
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/ooni/nettests/manipulation/http_header_field_manipulation.py b/ooni/nettests/manipulation/http_header_field_manipulation.py
index 3423442..6717cc1 100644
--- a/ooni/nettests/manipulation/http_header_field_manipulation.py
+++ b/ooni/nettests/manipulation/http_header_field_manipulation.py
@@ -11,7 +11,7 @@ from twisted.python import usage
from ooni.utils import log, net, randomStr
from ooni.templates import httpt
-from ooni.utils.txagentwithsocks import TrueHeaders
+from ooni.utils.trueheaders import TrueHeaders
def random_capitalization(string):
output = ""
diff --git a/ooni/oonibclient.py b/ooni/oonibclient.py
index 555d99c..f05c5e7 100644
--- a/ooni/oonibclient.py
+++ b/ooni/oonibclient.py
@@ -46,11 +46,16 @@ class OONIBClient(object):
retries = 3
def __init__(self, address):
- self.address = address
- self.agent = SOCKS5Agent(reactor,
+ if address.startswith('httpo://'):
+ self.address = address.replace('httpo://', 'http://')
+ self.agent = SOCKS5Agent(reactor,
proxyEndpoint=TCP4ClientEndpoint(reactor, '127.0.0.1',
config.tor.socks_port))
+ elif address.startswith('https://'):
+ log.err("HTTPS based bouncers are currently not supported.")
+
+
def _request(self, method, urn, genReceiver, bodyProducer=None):
attempts = 0
@@ -71,6 +76,7 @@ class OONIBClient(object):
# we have reached the retry count.
if attempts < self.retries:
log.err("Lookup failed. Retrying.")
+ log.exception(err)
attempts += 1
perform_request()
else:
diff --git a/ooni/reporter.py b/ooni/reporter.py
index b5fcce8..7566ca5 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -17,6 +17,8 @@ from twisted.trial import reporter
from twisted.internet import defer, reactor
from twisted.internet.error import ConnectionRefusedError
from twisted.python.failure import Failure
+from twisted.internet.endpoints import TCP4ClientEndpoint
+from twisted.web.client import Agent
from ooni.utils import log
@@ -35,7 +37,6 @@ from ooni.utils.net import BodyReceiver, StringProducer, userAgents
from ooni.settings import config
from ooni.tasks import ReportEntry, TaskTimedOut, ReportTracker
-
class ReporterException(Exception):
pass
@@ -289,13 +290,18 @@ class OONIBReporter(OReporter):
# do this with some deferred kung foo or instantiate the reporter after
# tor is started.
- from ooni.utils.txagentwithsocks import Agent
+ from ooni.utils.trueheaders import SOCKS5Agent
from twisted.internet import reactor
- try:
- self.agent = Agent(reactor, sockshost="127.0.0.1",
- socksport=int(config.tor.socks_port))
- except Exception, e:
- log.exception(e)
+
+ if self.collectorAddress.startswith('httpo://'):
+ self.collectorAddress.replace('httpo://', 'http://')
+ self.agent = SOCKS5Agent(reactor,
+ proxyEndpoint=TCP4ClientEndpoint(reactor, '127.0.0.1',
+ config.tor.socks_port))
+
+ elif self.collectorAddress.startswith('https://'):
+ # XXX add support for securely reporting to HTTPS collectors.
+ log.err("HTTPS based collectors are currently not supported.")
url = self.collectorAddress + '/report'
diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 9a44c18..b6272e9 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -19,7 +19,7 @@ from ooni.settings import config
from ooni.utils.net import BodyReceiver, StringProducer, userAgents
-from ooni.utils.txagentwithsocks import TrueHeaders
+from ooni.utils.trueheaders import TrueHeaders
from ooni.errors import handleAllFailures
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits