[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Make the getAddresses function more robust
commit c8d63868c393a903fa80c08fee3efa55cbfa19f7
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Fri Mar 7 13:41:58 2014 +0100
Make the getAddresses function more robust
---
ooni/nettests/manipulation/parasitictraceroute.py | 2 +-
ooni/utils/txscapy.py | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ooni/nettests/manipulation/parasitictraceroute.py b/ooni/nettests/manipulation/parasitictraceroute.py
index 7820721..c8aa3ed 100644
--- a/ooni/nettests/manipulation/parasitictraceroute.py
+++ b/ooni/nettests/manipulation/parasitictraceroute.py
@@ -33,7 +33,7 @@ class ParasiticTracerouteTest(scapyt.BaseScapyTest):
if k in self.pt.matched_packets:
ttl = self.pt.matched_packets[k]['ttl']
else:
- ttl = 'Unknown'
+ ttl = 'unknown'
hop = (ttl, packet.src)
path = 'hops_%s' % packet[IPerror].dst
if path in self.report['parasitic_traceroute']:
diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py
index 16d8e7e..a96a397 100644
--- a/ooni/utils/txscapy.py
+++ b/ooni/utils/txscapy.py
@@ -108,8 +108,14 @@ class IfaceError(Exception):
def getAddresses():
from scapy.all import get_if_addr, get_if_list
from ipaddr import IPAddress
- addresses = set([get_if_addr(i) for i in get_if_list()])
- addresses.remove('0.0.0.0')
+ addresses = set()
+ for i in get_if_list():
+ try:
+ addresses.add(get_if_addr(i))
+ except:
+ pass
+ if '0.0.0.0' in addresses:
+ addresses.remove('0.0.0.0')
return [IPAddress(addr) for addr in addresses]
def getDefaultIface():
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits