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

[tor-commits] [stem/master] Replace microdescriptor router status entry digest attribute



commit e30b130482be258245a4a28774959ecb2def58ed
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Nov 21 10:42:20 2018 -0800

    Replace microdescriptor router status entry digest attribute
    
    Bah. Back when I added our 'digest' attribute to RouterStatusEntryMicroV3 I
    tried to be consistent by making all our hashes hex. However, this was a
    mistake. Uses of the microdescriptor digest expect base64 so deprecating the
    'digest' attribute with another 'microdescriptor_digest' that's base64.
---
 docs/change_log.rst                         |  1 +
 stem/descriptor/router_status_entry.py      | 12 +++++++++++-
 test/unit/descriptor/router_status_entry.py |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index e99e933f..7b99f8f0 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -56,6 +56,7 @@ The following are only available within Stem's `git repository
   * Added the **hash_type** and **encoding** arguments to `ServerDescriptor <api/descriptor/server_descriptor.html#stem.descriptor.server_descriptor.ServerDescriptor.digest>`_ and `ExtraInfo's <api/descriptor/extrainfo_descriptor.html#stem.descriptor.extrainfo_descriptor.ExtraInfoDescriptor.digest>`_ digest methods (:trac:`28398`)
   * Added the network status vote's new bandwidth_file_digest attribute (:spec:`1b686ef`)
   * Added :func:`~stem.descriptor.networkstatus.NetworkStatusDocumentV3.is_valid` and :func:`~stem.descriptor.networkstatus.NetworkStatusDocumentV3.is_fresh` methods (:trac:`28448`)
+  * Replaced :func:`~stem.descriptor.router_status_entry.RouterStatusEntryMicroV3` hex encoded **digest** attribute with a base64 encoded **microdescriptor_digest**
   * DescriptorDownloader crashed if **use_mirrors** is set (:trac:`28393`)
   * Don't download from Serge, a bridge authority that frequently timeout
 
diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py
index b4cd506a..7e88c89a 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -342,6 +342,10 @@ def _parse_microdescriptor_m_line(descriptor, entries):
   # "m" digest
   # example: m aiUklwBrua82obG5AsTX+iEpkjQA2+AQHxZ7GwMfY70
 
+  descriptor.microdescriptor_digest = _value('m', entries)
+
+  # TODO: drop the following in stem 2.x
+
   descriptor.digest = _base64_to_hex(_value('m', entries), check_if_fingerprint = False)
 
 
@@ -672,7 +676,9 @@ class RouterStatusEntryMicroV3(RouterStatusEntry):
     information that isn't yet recognized
   :var dict protocols: mapping of protocols to their supported versions
 
-  :var str digest: **\*** router's hex encoded digest of our corresponding microdescriptor
+  :var str digest: **\*** router's hex encoded digest of our corresponding
+    microdescriptor (**deprecated**, use microdescriptor_digest instead)
+  :var str microdescriptor_digest: **\*** router's base64 encoded digest of our corresponding microdescriptor
 
   .. versionchanged:: 1.6.0
      Added the protocols attribute.
@@ -680,6 +686,9 @@ class RouterStatusEntryMicroV3(RouterStatusEntry):
   .. versionchanged:: 1.7.0
      Added the or_addresses attribute.
 
+  .. versionchanged:: 1.7.0
+     Added the microdescriptor_digest attribute to replace our now deprecated digest attribute.
+
   **\*** attribute is either required when we're parsed with validation or has
   a default value, others are left as **None** if undefined
   """
@@ -692,6 +701,7 @@ class RouterStatusEntryMicroV3(RouterStatusEntry):
     'unrecognized_bandwidth_entries': ([], _parse_w_line),
     'protocols': ({}, _parse_pr_line),
 
+    'microdescriptor_digest': (None, _parse_microdescriptor_m_line),
     'digest': (None, _parse_microdescriptor_m_line),
   })
 
diff --git a/test/unit/descriptor/router_status_entry.py b/test/unit/descriptor/router_status_entry.py
index 9d8bf8ac..05b4dee6 100644
--- a/test/unit/descriptor/router_status_entry.py
+++ b/test/unit/descriptor/router_status_entry.py
@@ -163,6 +163,7 @@ class TestRouterStatusEntry(unittest.TestCase):
     self.assertEqual(expected_flags, set(entry.flags))
     self.assertEqual(None, entry.version_line)
     self.assertEqual(None, entry.version)
+    self.assertEqual('aiUklwBrua82obG5AsTX+iEpkjQA2+AQHxZ7GwMfY70', entry.microdescriptor_digest)
     self.assertEqual('6A252497006BB9AF36A1B1B902C4D7FA2129923400DBE0101F167B1B031F63BD', entry.digest)
     self.assertEqual([], entry.get_unrecognized_lines())
 



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