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

[tor-commits] [ooni-probe/master] Register scapyFactor if it is not registered



commit 29505b25df7b133d634c9c0b5b5f33be12be7adf
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Sun Nov 25 16:31:47 2012 +0100

    Register scapyFactor if it is not registered
    * Better debugging messages
---
 ooni/config.py           |    1 +
 ooni/templates/scapyt.py |    7 ++++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/ooni/config.py b/ooni/config.py
index 5168c34..b017e87 100644
--- a/ooni/config.py
+++ b/ooni/config.py
@@ -14,6 +14,7 @@ from ooni.utils import Storage
 reports = Storage()
 basic = None
 cmd_line_options = None
+scapyFactory = None
 
 def get_root_path():
     this_directory = os.path.dirname(__file__)
diff --git a/ooni/templates/scapyt.py b/ooni/templates/scapyt.py
index cb02300..a1eade4 100644
--- a/ooni/templates/scapyt.py
+++ b/ooni/templates/scapyt.py
@@ -16,7 +16,7 @@ from ooni.nettest import NetTestCase
 from ooni.utils import log
 from ooni import config
 
-from ooni.utils.txscapy import ScapySender, getDefaultIface
+from ooni.utils.txscapy import ScapySender, getDefaultIface, ScapyFactory
 
 class BaseScapyTest(NetTestCase):
     """
@@ -42,6 +42,10 @@ class BaseScapyTest(NetTestCase):
             ]
 
     def _setUp(self):
+        if not config.scapyFactory:
+            log.debug("Scapy factoring not set, registering it.")
+            config.scapyFactory = ScapyFactory(config.advanced.interface)
+
         self.report['answer_flags'] = []
         if self.localOptions['ipsrc']:
             config.checkIPsrc = 0
@@ -98,6 +102,7 @@ class BaseScapyTest(NetTestCase):
         scapySender = ScapySender()
 
         config.scapyFactory.registerProtocol(scapySender)
+        log.debug("Using sending with hash %s" % scapySender.__hash__)
 
         d = scapySender.startSending(packets)
         d.addCallback(self.finishedSendReceive)

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