[tor-commits] [ooni-probe/master] Detect default interface with the one that is the default gateway.

art at torproject.org art at torproject.org
Tue Aug 5 10:33:36 UTC 2014


commit 34d402d34cc2a610538f8603809dd6753e48c783
Author: kudrom <kudrom at riseup.net>
Date:   Sun Jul 20 21:27:13 2014 +0200

    Detect default interface with the one that is the default gateway.
---
 ooni/utils/txscapy.py |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py
index 340885a..54b4102 100644
--- a/ooni/utils/txscapy.py
+++ b/ooni/utils/txscapy.py
@@ -124,13 +124,9 @@ def getAddresses():
 
 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:
-            return net.iface
+    for route in read_routes():
+        if route[2] == '0.0.0.0' and route[3] != 'lo':
+            return route[3]
     raise IfaceError
 
 





More information about the tor-commits mailing list