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

[tor-commits] [stem/master] Supporting multiple extra-info transport lines



commit a0f980c996587ef112379891339d463bda3d487a
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Jul 9 12:00:08 2012 -0700

    Supporting multiple extra-info transport lines
    
    The 'transport' lines being added to extra-info descriptors can appear any
    number of times, so storing them as a list. These options are weird in that
    they have an "address:port [arglist]" which never appears in the wild since
    they both only appear on bridge descriptors and are scrubbed from bridge
    descripotrs.
---
 stem/descriptor/extrainfo_descriptor.py      |   11 +++++++++--
 test/unit/descriptor/extrainfo_descriptor.py |    2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index b1c7b09..366279c 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -743,7 +743,7 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
   """
   Bridge extra-info descriptor (`specification <https://metrics.torproject.org/formats.html#bridgedesc>`_)
   
-  :var str transport: transport method recognized by the bridge (ex. obfs3)
+  :var list transport: transport method recognized by the bridge (ex. obfs3)
   """
   
   def __init__(self, raw_contents, validate = True):
@@ -764,7 +764,14 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
       line = "%s %s" % (keyword, value) # original line
       
       if keyword == "transport":
-        self.transport = value
+        # "transport" transportname address:port [arglist]
+        # Everything after the transportname is scrubbed in published bridge
+        # descriptors, so we'll never see it in practice.
+        
+        if self.transport is None:
+          self.transport = []
+        
+        self.transport.append(value)
         del entries["transport"]
       elif keyword == "router-digest":
         if validate and not stem.util.tor_tools.is_hex_digits(value, 40):
diff --git a/test/unit/descriptor/extrainfo_descriptor.py b/test/unit/descriptor/extrainfo_descriptor.py
index e9b06a0..a3590ee 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -529,7 +529,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
     
     desc_text = _make_descriptor({"transport": "obfs3"}, is_bridge = True)
     desc = BridgeExtraInfoDescriptor(desc_text)
-    self.assertEquals("obfs3", desc.transport)
+    self.assertEquals(["obfs3"], desc.transport)
     self.assertEquals([], desc.get_unrecognized_lines())
   
   def _expect_invalid_attr(self, desc_text, attr = None, expected_value = None):



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