commit f965f0aa8c8e8a7b6eeb5373a4703c2857e1c5e1 Author: aagbsn aagbsn@extc.org Date: Fri Feb 22 16:43:54 2013 +0100
Wait until Tor has started before adding reporters
As we get the client IP from Tor, we need to wait until Tor has bootstrapped (if start_tor is set) before setting up the reporters.
Note that we should try and get the client IP by an alternate mechanism if start_tor is not enabled in ooniprobe.conf or if we are unable to get the client IP from Tor. --- ooni/oonicli.py | 49 ++++++++++++++++++++++++++----------------------- 1 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/ooni/oonicli.py b/ooni/oonicli.py index 77d4549..dd03a08 100644 --- a/ooni/oonicli.py +++ b/ooni/oonicli.py @@ -115,11 +115,7 @@ def runWithDirector(): log.debug("No test deck detected") test_list.append(NetTestLoader(global_options['test'], net_test_args))
- - - director = Director() - d = director.start() - + # check each test's usageOptions for net_test_loader in test_list: try: net_test_loader.checkOptions() @@ -132,22 +128,29 @@ def runWithDirector(): print net_test_loader.usageOptions().getUsage() sys.exit(2)
- yaml_reporter = YAMLReporter(net_test_loader.testDetails) - reporters = [yaml_reporter] - - if global_options['collector']: - try: - oonib_reporter = OONIBReporter(net_test_loader.testDetails, - global_options['collector']) - reporters.append(oonib_reporter) - except InvalidOONIBCollectorAddress: - log.err("Invalid format for oonib collector address.") - log.msg("Should be in the format http://<collector_address>:<port>") - log.msg("for example: ooniprobe -c httpo://nkvphnp3p6agi5qq.onion") - sys.exit(1) - - #XXX add all the tests to be run sequentially - d.addCallback(director.startNetTest, net_test_loader, reporters) - d.addCallback(shutdown) - #XXX: if errback is called they do not propagate + director = Director() + d = director.start() + + # Wait until director has started up (including bootstrapping Tor) before adding tess + def post_director_start(_): + for net_test_loader in test_list: + yaml_reporter = YAMLReporter(net_test_loader.testDetails) + reporters = [yaml_reporter] + + if global_options['collector']: + try: + oonib_reporter = OONIBReporter(net_test_loader.testDetails, + global_options['collector']) + reporters.append(oonib_reporter) + except InvalidOONIBCollectorAddress: + log.err("Invalid format for oonib collector address.") + log.msg("Should be in the format http://<collector_address>:<port>") + log.msg("for example: ooniprobe -c httpo://nkvphnp3p6agi5qq.onion") + sys.exit(1) + + #XXX add all the tests to be run sequentially + log.debug("adding callback for startNetTest") + d.addCallback(director.startNetTest, net_test_loader, reporters) + d.addCallback(shutdown) + d.addCallback(post_director_start) reactor.run()