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

[tor-commits] [stem/master] Differentiating read bridge and relay descriptors



commit c3fddad00ecad4ea5a94dafcfe6a0aaa10c4cfd0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Apr 11 21:12:26 2012 -0700

    Differentiating read bridge and relay descriptors
    
    The last integ failure was due to our attempt to read a bridge descriptor file
    as a relay descriptor, which doesn't work because it is missing cryptographic
    entries. Adding a bit of logic to differentiate relay from bridge descriptors
    so we can parse them as their appropriate type. The cues the difference based
    on the 'Unnamed' nickname and '10.x.x.x' address scrubbing.
---
 stem/descriptor/__init__.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 21f40c2..0e90546 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -40,7 +40,15 @@ def parse_file(path, descriptor_file):
   first_line = descriptor_file.readline()
   descriptor_file.seek(0)
   
-  if filename == "cached-descriptors" or first_line.startswith("router "):
+  if first_line.startswith("router Unnamed 10."):
+    # bridge descriptors are scrubbed so their nickname is 'Unnamed' and their
+    # ip address is in the 10.x.x.x space, which is normally reserved for
+    # private networks
+    
+    desc = stem.descriptor.server_descriptor.BridgeDescriptorV3(descriptor_file.read())
+    desc._set_path(path)
+    yield desc
+  elif filename == "cached-descriptors" or first_line.startswith("router "):
     for desc in stem.descriptor.server_descriptor.parse_file_v3(descriptor_file):
       desc._set_path(path)
       yield desc



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