[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Implement basic BridgeT test



commit 075d03666fa9a96ca951fad805a1c0664e5010e1
Author: Arturo Filastò <hellais@xxxxxxxxxxxxxx>
Date:   Sat Jun 2 14:03:07 2012 +0200

    Implement basic BridgeT test
---
 ooni/plugins/bridget.py |   72 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/ooni/plugins/bridget.py b/ooni/plugins/bridget.py
new file mode 100644
index 0000000..0614d5d
--- /dev/null
+++ b/ooni/plugins/bridget.py
@@ -0,0 +1,72 @@
+"""
+This is a self genrated test created by scaffolding.py.
+you will need to fill it up with all your necessities.
+Safe hacking :).
+"""
+from zope.interface import implements
+from twisted.python import usage
+from twisted.plugin import IPlugin
+from twisted.internet import reactor
+
+from ooni import log
+from ooni.plugoo.tests import ITest, OONITest
+from ooni.plugoo.assets import Asset
+
+class bridgetArgs(usage.Options):
+    optParameters = [['bridges', 'b', None, 'List of bridges to scan'],
+                     ['relays', 'f', None, 'List of relays to scan'],
+                     ['resume', 'r', 0, 'Resume at this index']]
+
+class bridgetTest(OONITest):
+    implements(IPlugin, ITest)
+
+    shortName = "bridget"
+    description = "bridget"
+    requirements = None
+    options = bridgetArgs
+    blocking = False
+
+    def experiment(self, args):
+        log.msg("Doing test")
+        # What you return here gets handed as input to control
+        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))
+
+        def setup_failed(args):
+            log.msg("Setup Failed.")
+            report.update({'failed': args})
+            return report
+
+        def setup_complete(proto):
+            log.msg("Setup Complete.")
+            report.update({'success': args})
+            return report
+
+        config = TorConfig()
+        config.SocksPort = 9999
+        config.OrPort = 1234
+        if 'bridge' in args:
+            config.UseBridges = 1
+            config.Bridge = args['bridge']
+        config.save()
+        report = {'tor_config': config.config}
+        log.msg("Starting Tor")
+        d = launch_tor(config, reactor, progress_updates=updates)
+        d.addCallback(setup_complete)
+        d.addErrback(setup_failed)
+        return d
+
+    def load_assets(self):
+        assets = {}
+        if self.local_options:
+            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'])})
+        return assets
+
+# We need to instantiate it otherwise getPlugins does not detect it
+# XXX Find a way to load plugins without instantiating them.
+bridget = bridgetTest(None, None, None)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits