commit 984497610ebc1efbf474b5dbd3fcc7e89c88fedd
Author: Damian Johnson <atagar(a)torproject.org>
Date: Fri Jun 30 11:06:51 2017 -0700
Add a make_router_status_entry method
Little helper to make router status entries that are derived from a server
descriptor. This presently populates just the base router status entry fields,
not the optional v3 fields. Happy to have it expanded if folks need that
though.
---
stem/descriptor/server_descriptor.py | 29 ++++++++++++…
[View More]+++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 643831b..edd1612 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -21,6 +21,7 @@ etc). This information is provided from a few sources...
ServerDescriptor - Tor server descriptor.
|- RelayDescriptor - Server descriptor for a relay.
+ | +- make_router_status_entry - Creates a router status entry for this descriptor.
|
|- BridgeDescriptor - Scrubbed server descriptor for a bridge.
| |- is_scrubbed - checks if our content has been properly scrubbed
@@ -46,6 +47,7 @@ import stem.util.str_tools
import stem.util.tor_tools
import stem.version
+from stem.descriptor.router_status_entry import RouterStatusEntryV3
from stem.util import str_type
from stem.descriptor import (
@@ -855,6 +857,33 @@ class RelayDescriptor(ServerDescriptor):
return self._digest_for_content(b'router ', b'\nrouter-signature\n')
+ def make_router_status_entry(self):
+ """
+ Provides a RouterStatusEntryV3 for this descriptor content.
+
+ .. versionadded:: 1.6.0
+
+ :returns: :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3`
+ that would be in the consensus
+ """
+
+ attr = {
+ 'r': ' '.join([
+ self.nickname,
+ base64.b64encode(binascii.unhexlify(self.fingerprint)).rstrip('='),
+ base64.b64encode(binascii.unhexlify(self.digest())).rstrip('='),
+ self.published.strftime('%Y-%m-%d %H:%M:%S'),
+ self.address,
+ str(self.or_port),
+ str(self.dir_port) if self.dir_port else '0',
+ ]),
+ }
+
+ if self.tor_version:
+ attr['v'] = self.tor_version
+
+ return RouterStatusEntryV3.create(attr)
+
@lru_cache()
def onion_key_crosscert_digest(self):
"""
[View Less]
commit 02eb36058f91f88952378df76bc8584fa8a95ee0
Author: Damian Johnson <atagar(a)torproject.org>
Date: Fri Jun 30 10:25:57 2017 -0700
Populate fingerprints for created server descriptors
Not technically a mandatory field but lets be honest, if you provide a signing
key you want this. ;P
---
stem/descriptor/server_descriptor.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index …
[View More]42cbca6..643831b 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -826,6 +826,10 @@ class RelayDescriptor(ServerDescriptor):
if signing_key is None:
signing_key = create_signing_key()
+ if 'fingerprint' not in attr:
+ fingerprint = hashlib.sha1(_bytes_for_block(signing_key.public_digest.strip())).hexdigest().upper()
+ attr['fingerprint'] = ' '.join(stem.util.str_tools._split_by_length(fingerprint, 4))
+
attr['signing-key'] = signing_key.public_digest
content = _descriptor_content(attr, exclude, sign, base_header) + b'\nrouter-signature\n'
[View Less]
commit ee8921e348828228d0cc0364e9d7433dfd7b9885
Author: Damian Johnson <atagar(a)torproject.org>
Date: Fri Jun 30 09:38:40 2017 -0700
Cite metrics-lib's shiny new site
---
docs/tutorials/mirror_mirror_on_the_wall.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/tutorials/mirror_mirror_on_the_wall.rst b/docs/tutorials/mirror_mirror_on_the_wall.rst
index d215722..8ff63f5 100644
--- a/docs/tutorials/mirror_mirror_on_the_wall.rst
+++ b/docs/tutorials/…
[View More]mirror_mirror_on_the_wall.rst
@@ -307,7 +307,7 @@ Are there any other parsing libraries?
--------------------------------------
Yup! Stem isn't the only game in town when it comes to parsing. `Metrics-lib
-<https://gitweb.torproject.org/metrics-lib.git/>`_ is a highly mature parsing
+<https://metrics.torproject.org/metrics-lib.html>`_ is a highly mature parsing
library for Java, and `Zoossh
<https://gitweb.torproject.org/user/phw/zoossh.git/>`_ is available for Go.
Each library has its own capabilities...
[View Less]