[tor-commits] [stem/master] Directory authority's dir-source has its v3ident, not fingerprint

atagar at torproject.org atagar at torproject.org
Thu Feb 19 18:12:24 UTC 2015


commit 52ba4b35fed17a1e0bded2b4e850a979ce08041f
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Feb 19 10:03:15 2015 -0800

    Directory authority's dir-source has its v3ident, not fingerprint
    
    The authority entries in the consensus have the authority's v3ident, not its
    fingerprint. That is to say, our DirectoryAuthority class' attribute was
    misnamed.
---
 docs/change_log.rst              |    1 +
 stem/descriptor/networkstatus.py |   30 ++++++++++++++++++------------
 test/integ/descriptor/remote.py  |    2 +-
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 945a52f..178fea4 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -56,6 +56,7 @@ conversion (:trac:`14075`).
  * **Descriptors**
 
   * Lazy-loading descriptors, improving performance by 25-70% depending on what type it is (:trac:`14011`)
+  * The :class:`~stem.descriptor.networkstatus.DirectoryAuthority` 'fingerprint' attribute was actually its 'v3ident'
 
  * **Utilities**
 
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index b356787..f465e6f 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -1006,7 +1006,7 @@ def _parse_int_mappings(keyword, value, validate):
   return results
 
 
-def _parse_dir_source_line(descriptor, entries):
+def _parse_dirauth_source_line(descriptor, entries):
   # "dir-source" nickname identity address IP dirport orport
 
   value = _value('dir-source', entries)
@@ -1018,7 +1018,7 @@ def _parse_dir_source_line(descriptor, entries):
   if not stem.util.tor_tools.is_valid_nickname(dir_source_comp[0].rstrip('-legacy')):
     raise ValueError("Authority's nickname is invalid: %s" % dir_source_comp[0])
   elif not stem.util.tor_tools.is_valid_fingerprint(dir_source_comp[1]):
-    raise ValueError("Authority's fingerprint is invalid: %s" % dir_source_comp[1])
+    raise ValueError("Authority's v3ident is invalid: %s" % dir_source_comp[1])
   elif not dir_source_comp[2]:
     # https://trac.torproject.org/7055
     raise ValueError("Authority's hostname can't be blank: dir-source %s" % value)
@@ -1030,7 +1030,7 @@ def _parse_dir_source_line(descriptor, entries):
     raise ValueError("Authority's ORPort is invalid: %s" % dir_source_comp[5])
 
   descriptor.nickname = dir_source_comp[0]
-  descriptor.fingerprint = dir_source_comp[1]
+  descriptor.v3ident = dir_source_comp[1]
   descriptor.hostname = dir_source_comp[2]
   descriptor.address = dir_source_comp[3]
   descriptor.dir_port = None if dir_source_comp[4] == '0' else int(dir_source_comp[4])
@@ -1053,7 +1053,7 @@ class DirectoryAuthority(Descriptor):
   * There's no **contact** or **vote_digest** attribute.
 
   :var str nickname: **\*** authority's nickname
-  :var str fingerprint: **\*** authority's fingerprint
+  :var str v3ident: **\*** identity key fingerprint used to sign votes and consensus
   :var str hostname: **\*** hostname of the authority
   :var str address: **\*** authority's IP address
   :var int dir_port: **\*** authority's DirPort
@@ -1075,20 +1075,20 @@ class DirectoryAuthority(Descriptor):
   """
 
   ATTRIBUTES = {
-    'nickname': (None, _parse_dir_source_line),
-    'fingerprint': (None, _parse_dir_source_line),
-    'hostname': (None, _parse_dir_source_line),
-    'address': (None, _parse_dir_source_line),
-    'dir_port': (None, _parse_dir_source_line),
-    'or_port': (None, _parse_dir_source_line),
-    'is_legacy': (False, _parse_dir_source_line),
+    'nickname': (None, _parse_dirauth_source_line),
+    'v3ident': (None, _parse_dirauth_source_line),
+    'hostname': (None, _parse_dirauth_source_line),
+    'address': (None, _parse_dirauth_source_line),
+    'dir_port': (None, _parse_dirauth_source_line),
+    'or_port': (None, _parse_dirauth_source_line),
+    'is_legacy': (False, _parse_dirauth_source_line),
     'contact': (None, _parse_contact_line),
     'vote_digest': (None, _parse_vote_digest_line),
     'legacy_dir_key': (None, _parse_legacy_dir_key_line),
   }
 
   PARSER_FOR_LINE = {
-    'dir-source': _parse_dir_source_line,
+    'dir-source': _parse_dirauth_source_line,
     'contact': _parse_contact_line,
     'legacy-dir-key': _parse_legacy_dir_key_line,
     'vote-digest': _parse_vote_digest_line,
@@ -1168,6 +1168,12 @@ class DirectoryAuthority(Descriptor):
     else:
       self._entries = entries
 
+    # TODO: Due to a bug we had a 'fingerprint' rather than 'v3ident' attribute
+    # for a long while. Keeping this around for backward compatability, but
+    # this will be dropped in stem's 2.0 release.
+
+    self.fingerprint = self.v3ident
+
   def _compare(self, other, method):
     if not isinstance(other, DirectoryAuthority):
       return False
diff --git a/test/integ/descriptor/remote.py b/test/integ/descriptor/remote.py
index 61370d2..2f09597 100644
--- a/test/integ/descriptor/remote.py
+++ b/test/integ/descriptor/remote.py
@@ -35,7 +35,7 @@ class TestDescriptorDownloader(unittest.TestCase):
       if not stem_auth:
         self.fail("%s isn't a recognized directory authority in stem" % auth.nickname)
 
-      for attr in ('address', 'fingerprint', 'or_port', 'dir_port'):
+      for attr in ('address', 'v3ident', 'or_port', 'dir_port'):
         if getattr(auth, attr) != getattr(stem_auth, attr):
           self.fail("%s has %s %s, but we expected %s" % (auth.nickname, attr, getattr(auth, attr), getattr(stem_auth, attr)))
 





More information about the tor-commits mailing list