[ooni-probe/master] If libpcap and libdnet is present we will use them. If not use raw sockets.

commit 3d100e9495bf2459e13bba73a2eaa8f1cd58d521 Author: Arturo Filastò <art@fuffa.org> Date: Sat Nov 24 23:04:40 2012 +0100 If libpcap and libdnet is present we will use them. If not use raw sockets. --- ooni/utils/net.py | 1 - ooni/utils/txscapy.py | 32 ++++++++++++++++++++++++-------- ooniprobe.conf | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ooni/utils/net.py b/ooni/utils/net.py index e828977..649dc64 100644 --- a/ooni/utils/net.py +++ b/ooni/utils/net.py @@ -15,7 +15,6 @@ from zope.interface import implements from twisted.internet import protocol, defer from twisted.internet import threads, reactor from twisted.web.iweb import IBodyProducer -from scapy.all import utils from ooni.utils import log, txscapy diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py index 432a987..679eb42 100644 --- a/ooni/utils/txscapy.py +++ b/ooni/utils/txscapy.py @@ -17,13 +17,30 @@ from twisted.internet import reactor, threads, error from twisted.internet import defer, abstract from zope.interface import implements -from scapy.all import PcapWriter, MTU -from scapy.all import BasePacketList, conf, PcapReader - -from scapy.all import conf, Gen, SetGen -from scapy.arch import pcapdnet +from scapy.config import conf from ooni.utils import log +from ooni import config + +try: + conf.use_pcap = True + conf.use_dnet = True + + from scapy.all import PcapWriter + from scapy.arch import pcapdnet + + config.pcap_dnet = True + +except ImportError, e: + log.err("pypcap or dnet not installed. Certain tests may not work.") + config.pcap_dnet = False + conf.use_pcap = False + conf.use_dnet = False + + from scapy.all import PcapWriter + +from scapy.all import BasePacketList, conf, PcapReader +from scapy.all import conf, Gen, SetGen, MTU def getNetworksFromRoutes(): from scapy.all import conf, ltoa, read_routes @@ -58,9 +75,8 @@ class ScapyProtocol(abstract.FileDescriptor): def __init__(self, interface, super_socket=None, timeout=5): abstract.FileDescriptor.__init__(self, reactor) if not super_socket: - # XXX this is what we would want - #super_socket = pcapdnet.L3dnetSocket(iface=interface) - super_socket = conf.L3Socket(iface=interface) + super_socket = conf.L3socket(iface=interface, promisc=True, filter='') + #super_socket = conf.L2socket(iface=interface) fdesc._setCloseOnExec(super_socket.ins.fileno()) self.super_socket = super_socket diff --git a/ooniprobe.conf b/ooniprobe.conf index e9f208f..ad761e1 100644 --- a/ooniprobe.conf +++ b/ooniprobe.conf @@ -22,7 +22,7 @@ advanced: # /path/to/ooni-probe/data/ #geoip_data_dir: /usr/share/GeoIP/ geoip_data_dir: /home/x/code/networking/ooni-probe/data/ - debug: true + debug: false threadpool_size: 10 tor_socksport: 9050 # For auto detection
participants (1)
-
art@torproject.org