commit 5eb60817a2ed1771adf2a11ba3fe4041ed5a3df8 Author: aagbsn aagbsn@extc.org Date: Mon Feb 18 02:23:11 2013 +0100
Test for raw socket permission --- ooni/utils/txscapy.py | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py index 62bde94..d57a54b 100644 --- a/ooni/utils/txscapy.py +++ b/ooni/utils/txscapy.py @@ -75,6 +75,14 @@ def getDefaultIface(): return net.iface raise IfaceError
+def hasRawSocketPermission(): + from scapy.all import IP, send + try: + send(IP(src="1.2.3.4", dst="127.0.0.1")) + return True + except (socket.error, OSError): + return False + class ProtocolNotRegistered(Exception): pass