[tor-commits] [stem/master] Including deprecated server descriptor attributes

atagar at torproject.org atagar at torproject.org
Mon Mar 26 00:10:01 UTC 2012


commit b3d357b9f12d9bce72ec411f2681fdf84dcb4139
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Mar 25 12:15:15 2012 -0700

    Including deprecated server descriptor attributes
    
    I have mixed feelings about cluttering the server descriptor with dead fields,
    but since we're already this close to being perfectly spec conformant we might
    as well include this last bit. Adding the fields but logging an info level
    warning if we see it, and checking in our cached descriptor that they do not
    exist.
---
 stem/descriptor/server_descriptor.py       |   18 +++++++++++++++++-
 test/integ/descriptor/server_descriptor.py |    5 +++++
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 598571e..899cfcc 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -22,6 +22,7 @@ import stem.descriptor
 import stem.version
 import stem.util.connection
 import stem.util.tor_tools
+import stem.util.log as log
 
 ENTRY_START = "router"
 ENTRY_END   = "router-signature"
@@ -199,7 +200,7 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
     fingerprint (str)        - fourty hex digits that make up the relay's fingerprint
     address (str)            - IPv4 address of the relay (*)
     or_port (int)            - port used for relaying (*)
-    socks_port (int)         - deprecated attribute, always zero (*)
+    socks_port (int)         - (deprecated) always zero (*)
     dir_port (int)           - deprecated port used for descriptor mirroring (*)
     platform (str)           - operating system and tor version
     tor_version (stem.version.Version) - version of tor
@@ -219,6 +220,9 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
     average_bandwidth (int)  - rate of traffic relay is willing to relay in bytes/s (*)
     burst_bandwidth (int)    - rate of traffic relay is willing to burst to in bytes/s (*)
     observed_bandwidth (int) - estimated capacity of the relay based on usage in bytes/s (*)
+    read_history (str)       - (deprecated) always unset
+    write_history (str)      - (deprecated) always unset
+    eventdns (bool)          - (deprecated) always unset (*)
     onion_key (str)          - key used to encrypt EXTEND cells (*)
     signing_key (str)        - relay's long-term identity key (*)
     signature (str)          - signature for this descriptor (*)
@@ -271,6 +275,9 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
     self.average_bandwidth = None
     self.burst_bandwidth = None
     self.observed_bandwidth = None
+    self.read_history = None
+    self.write_history = None
+    self.eventdns = True
     self.onion_key = None
     self.signing_key = None
     self.signature = None
@@ -508,6 +515,15 @@ class ServerDescriptorV3(stem.descriptor.Descriptor):
           raise ValueError("Protocols line did not match the expected pattern: %s" % line)
       elif keyword == "family":
         self.family = value.split(" ")
+      elif keyword == "read-history":
+        log.info("Read an unexpected 'read-history' line in a v3 server descriptor. These should only appear in extra-info. line: %s" % line)
+        self.read_history = value
+      elif keyword == "write-history":
+        log.info("Read an unexpected 'write-history' line in a v3 server descriptor. These should only appear in extra-info. line: %s" % line)
+        self.write_history = value
+      elif keyword == "eventdns":
+        log.info("Read an unexpected 'eventdns' line in a v3 server descriptor. These should be deprecated. line: %s" % line)
+        self.eventdns = value == "1"
       else:
         self._unrecognized_lines.append(line)
   
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index a3a1e65..3782dea 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -109,6 +109,11 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
     
     with open(descriptor_path) as descriptor_file:
       for desc in stem.descriptor.server_descriptor.parse_file_v3(descriptor_file):
+        # the following attributes should be deprecated, and not appear in the wild
+        self.assertEquals(None, desc.read_history)
+        self.assertEquals(None, desc.write_history)
+        self.assertEquals(True, desc.eventdns)
+        
         unrecognized_lines = desc.get_unrecognized_lines()
         
         if unrecognized_lines:





More information about the tor-commits mailing list