[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Further progress on packet capture implementation
commit 9e632c5d7c8d7f73add3aa38900898a86f6ca9fc
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Thu Nov 8 21:46:28 2012 +0100
Further progress on packet capture implementation
---
ooni/config.py | 3 ++-
ooni/runner.py | 8 +++++---
ooni/utils/net.py | 4 +++-
ooniprobe.conf | 2 --
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ooni/config.py b/ooni/config.py
index 64bc973..faf830f 100644
--- a/ooni/config.py
+++ b/ooni/config.py
@@ -41,5 +41,6 @@ advanced = Storage()
for k, v in configuration['advanced'].items():
advanced[k] = v
-threadpool = ThreadPool(0, config.advanced.threadpool_size)
+threadpool = ThreadPool(0, advanced.threadpool_size)
threadpool.start()
+sniffer_d = None
diff --git a/ooni/runner.py b/ooni/runner.py
index 7e9a5d6..a6e0908 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -16,12 +16,13 @@ from twisted.python import reflect, usage
from twisted.trial.runner import isTestCase
from twisted.trial.runner import filenameToModule
+from twisted.internet import reactor, threads
from ooni.inputunit import InputUnitFactory
from ooni.nettest import InputTestSuite
from ooni.reporter import ReporterFactory
-from ooni.utils import log, date
+from ooni.utils import log, date, net
from ooni import config
def processTest(obj, cmd_line_options):
@@ -210,12 +211,13 @@ class ORunner(object):
idx += (suite._idx - idx)
log.debug("I am now at the index %s" % idx)
- log.debug("Finished")
+ log.debug("Finished running of all tests")
result.done()
-
config.threadpool.stop()
def run(self):
+ if config.privacy.includepcap:
+ config.sniffer_d = threads.deferToThreadPool(reactor, config.threadpool, net.capturePackets)
self.reporterFactory.options = self.options
for input_unit in InputUnitFactory(self.inputs):
self.runWithInputUnit(input_unit)
diff --git a/ooni/utils/net.py b/ooni/utils/net.py
index 46c29e5..3bebcdb 100644
--- a/ooni/utils/net.py
+++ b/ooni/utils/net.py
@@ -9,12 +9,14 @@
# :license: (c) 2012 Isis Lovecruft, Arturo Filasto
# see attached LICENCE file
-
def getClientAddress():
address = {'asn': 'REPLACE_ME',
'ip': 'REPLACE_ME'}
return address
+def capturePackets():
+ from scapy.all import sniff
+ sniff()
class PermissionsError(SystemExit):
def __init__(self, *args, **kwargs):
diff --git a/ooniprobe.conf b/ooniprobe.conf
index 3250c4d..058394e 100644
--- a/ooniprobe.conf
+++ b/ooniprobe.conf
@@ -5,7 +5,6 @@
basic:
# Where OONIProbe should be writing it's log file
logfile: /tmp/ooniprobe.log
-
privacy:
# Should we include the IP address of the probe in the report?
includeip: false
@@ -17,7 +16,6 @@ privacy:
includecity: false
# Should we collect a full packet capture on the client?
includepcap: true
-
advanced:
# XXX change this to point to the directory where you have stored the GeoIP
# database file. This should be the directory in which OONI is installed
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits