commit c09e7f9a98e7191332f39e6d70d7bb967c5e3e8a Author: Isis Lovecruft isis@torproject.org Date: Mon Sep 3 10:55:51 2012 +0000
BridgeT works again, but...
There seems to be a problem with it attempting to ControlPort to the same port as one of my local non-slave Tors, even though TorConfig() is still using random.randint(). I will investigate further after some much-needed sl33pzorzings. --- ooni/ooniprobe.log | 1 - ooni/plugins/bridget.py | 53 +++++++++++++++++++++++++++++++++------------- ooni/plugins/domclass.py | 3 +- 3 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/ooni/ooniprobe.log b/ooni/ooniprobe.log deleted file mode 100644 index 700e820..0000000 --- a/ooni/ooniprobe.log +++ /dev/null @@ -1 +0,0 @@ -2012-05-31 02:27:28,010 ooniprobe INFO Started ooni-probe diff --git a/ooni/plugins/bridget.py b/ooni/plugins/bridget.py index 22ff9a0..5562fb6 100644 --- a/ooni/plugins/bridget.py +++ b/ooni/plugins/bridget.py @@ -1,8 +1,17 @@ -""" -This is a self genrated test created by scaffolding.py. -you will need to fill it up with all your necessities. -Safe hacking :). -""" +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +# +# +-----------+ +# | BRIDGET | +# | +----------------------------------------------+ +# +--------| Use a slave Tor process to test making a Tor | +# | connection to a list of bridges or relays. | +# +----------------------------------------------+ +# +# :authors: Arturo Filasto, Isis Lovecruft, Jacob Appelbaum +# :licence: see included LICENSE +# :version: 0.1.0-alpha + from zope.interface import implements from twisted.python import usage from twisted.plugin import IPlugin @@ -21,34 +30,43 @@ class bridgetTest(OONITest): implements(IPlugin, ITest)
shortName = "bridget" - description = "bridget" + description = "Use a slave Tor process to test RELAY_EXTEND to bridges/relays" requirements = None options = bridgetArgs blocking = False
def experiment(self, args): - log.msg("Doing test") - # What you return here gets handed as input to control + log.msg("BridgeT: initiating test ... ") + from ooni.lib.txtorcon import TorProtocolFactory, TorConfig, TorState from ooni.lib.txtorcon import DEFAULT_VALUE, launch_tor - def updates(prog, tag, summary): - log.msg("%d%%: %s" % (prog, summary)) - return + + reactor = self.reactor
def setup_failed(args): log.msg("Setup Failed.") report.update({'failed': args}) - return report + reactor.stop() + #return report
def setup_complete(proto): - log.msg("Setup Complete.") + log.msg("Setup Complete: %s" % proto) + state = TorState(proto.tor_protocol) + state.post_bootstrap.addCallback(state_complete).addErrback(setup_failed) report.update({'success': args}) - return report + #return report + + def bootstrap(c): + conf = TorConfig(c) + conf.post_bootstrap.addCallback(setup_complete).addErrback(setup_failed) + log.msg("Slave Tor process connected, bootstrapping ...")
config = TorConfig() import random config.SocksPort = random.randint(1024, 2**16) config.ControlPort = random.randint(1024, 2**16) + #config.SocksPort = 12345 + #config.ControlPort = 12346
if 'bridge' in args: config.UseBridges = 1 @@ -57,6 +75,11 @@ class bridgetTest(OONITest): print config.create_torrc() report = {'tor_config': config.config} log.msg("Starting Tor") + + def updates(prog, tag, summary): + log.msg("%d%%: %s" % (prog, summary)) + #return + d = launch_tor(config, self.reactor, progress_updates=updates) d.addCallback(setup_complete) d.addErrback(setup_failed) @@ -68,7 +91,7 @@ class bridgetTest(OONITest): if self.local_options['bridges']: assets.update({'bridge': Asset(self.local_options['bridges'])}) elif self.local_options['relays']: - assets.update({'relay': Asset(self.local_options['relay'])}) + assets.update({'relay': Asset(self.local_options['relays'])}) return assets
# We need to instantiate it otherwise getPlugins does not detect it diff --git a/ooni/plugins/domclass.py b/ooni/plugins/domclass.py index cdcd508..c24f2ce 100644 --- a/ooni/plugins/domclass.py +++ b/ooni/plugins/domclass.py @@ -1,4 +1,5 @@ -# +#!/usr/bin/env python +#-*- encoding: utf-8 -*- # # domclass # ********