[tor-commits] [ooni-probe/master] Add docstrings to network helper functions

art at torproject.org art at torproject.org
Thu Dec 6 21:39:59 UTC 2012


commit 7f29689606b9661c53c4164c8bb660df87567223
Author: aagbsn <aagbsn at extc.org>
Date:   Thu Dec 6 12:20:14 2012 +0000

    Add docstrings to network helper functions
    
    Adds documentation for getDefaultIface and getNetworkFromRoutes.
    Also adds #XXX warning for users of OpenVZ environments.
---
 ooni/utils/txscapy.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py
index 7902133..210f21b 100644
--- a/ooni/utils/txscapy.py
+++ b/ooni/utils/txscapy.py
@@ -45,6 +45,7 @@ from scapy.all import BasePacketList, conf, PcapReader
 from scapy.all import conf, Gen, SetGen, MTU
 
 def getNetworksFromRoutes():
+    """ Return a list of networks from the routing table """
     from scapy.all import conf, ltoa, read_routes
     from ipaddr    import IPNetwork, IPAddress
 
@@ -65,6 +66,10 @@ class IfaceError(Exception):
     pass
 
 def getDefaultIface():
+    """ Return the default interface or raise IfaceError """
+    #XXX: currently broken on OpenVZ environments, because
+    # the routing table does not contain a default route
+    # Workaround: Set the default interface in ooniprobe.conf
     networks = getNetworksFromRoutes()
     for net in networks:
         if net.is_private:





More information about the tor-commits mailing list