[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [doctor/master] Support address ranges for relays we track



commit 44b3a702b34604d67cfaa0da50e5ae243e5c41c2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Feb 20 12:42:54 2016 -0800

    Support address ranges for relays we track
    
    Ewww, but Stem's ExitPolicy already supports exactly what we want in a
    delightfully efficient way so taking advantage of that.
---
 track_relays.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/track_relays.py b/track_relays.py
index a65356d..bc46216 100755
--- a/track_relays.py
+++ b/track_relays.py
@@ -10,6 +10,7 @@ import datetime
 import traceback
 
 import stem.descriptor.remote
+import stem.exit_policy
 import stem.util.conf
 
 import util
@@ -111,7 +112,10 @@ def main():
   for relay in get_tracked_relays():
     if relay.address:
       if '/' in relay.address:
-        tracked_address_ranges[relay.address] = relay
+        # It's a total hack, but taking advantage of exit policies where we
+        # already support address ranges.
+
+        tracked_address_ranges[stem.exit_policy.ExitPolicyRule('accept %s:*' % relay.address)] = relay
       else:
         tracked_addresses[relay.address] = relay
 
@@ -127,7 +131,9 @@ def main():
     elif desc.fingerprint in tracked_fingerprints:
       found_relays[tracked_fingerprints[desc.fingerprint]] = desc
     else:
-      pass  # TODO: implement for tracked_address_ranges
+      for addr_entry, relay in tracked_address_ranges.items():
+        if addr_entry.is_match(desc.address):
+          found_relays[relay] = desc
 
   if found_relays:
     log.debug("Sending a notification for %i relay entries..." % len(found_relays))

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits