[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Switching get_network_status() to provide v3 entries
commit 003fa8e9e4b38304ccbb28e75a3f646ab6ba1ab2
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Jun 25 08:57:42 2013 -0700
Switching get_network_status() to provide v3 entries
Turns out 'GETINFO ns/*' provides v3 directory information rather than the v2
documented in the spec. Now that the spec is fixed swapping us over to take
advantage of it...
https://trac.torproject.org/7953
https://gitweb.torproject.org/torspec.git/commitdiff/d2b7ebb
RouterStatusEntryV3 provides a superset of the attributes of
RouterStatusEntryV2 so backward compatability shouldn't be a concern.
---
docs/change_log.rst | 1 +
stem/control.py | 8 ++++----
test/integ/control/controller.py | 5 +++++
test/unit/control/controller.py | 2 +-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst
index a2c92ea..d7f6a53 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -40,6 +40,7 @@ The following are only available within stem's `git repository
* **Controller**
+ * :func:`~stem.control.Controller.get_network_status` and :func:`~stem.control.Controller.get_network_statuses` now provide v3 rather than v2 directory information (:trac:`7953`, :spec:`d2b7ebb`)
* :class:`~stem.response.events.AddrMapEvent` support for the new CACHED argument (:trac:`8596`, :spec:`25b0d43`)
* :func:`~stem.control.Controller.attach_stream` could encounter an undocumented 555 response (:trac:`8701`, :spec:`7286576`)
* :class:`~stem.descriptor.server_descriptor.RelayDescriptor` digest validation was broken when dealing with non-unicode content with python 3 (:trac:`8755`)
diff --git a/stem/control.py b/stem/control.py
index 5f9a745..8a8f410 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1250,7 +1250,7 @@ class Controller(BaseController):
:param str relay: fingerprint or nickname of the relay to be queried
:param object default: response if the query fails
- :returns: :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV2`
+ :returns: :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3`
for the given relay
:raises:
@@ -1275,7 +1275,7 @@ class Controller(BaseController):
raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
desc_content = self.get_info(query, get_bytes = True)
- return stem.descriptor.router_status_entry.RouterStatusEntryV2(desc_content)
+ return stem.descriptor.router_status_entry.RouterStatusEntryV3(desc_content)
except Exception as exc:
if default == UNDEFINED:
raise exc
@@ -1290,7 +1290,7 @@ class Controller(BaseController):
:param list default: items to provide if the query fails
:returns: iterates over
- :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV2` for
+ :class:`~stem.descriptor.router_status_entry.RouterStatusEntryV3` for
relays in the tor network
:raises: :class:`stem.ControllerError` if unable to query tor and no
@@ -1308,7 +1308,7 @@ class Controller(BaseController):
desc_iterator = stem.descriptor.router_status_entry._parse_file(
io.BytesIO(desc_content),
True,
- entry_class = stem.descriptor.router_status_entry.RouterStatusEntryV2,
+ entry_class = stem.descriptor.router_status_entry.RouterStatusEntryV3,
)
for desc in desc_iterator:
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index c4b8fb1..801d979 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -980,6 +980,11 @@ class TestController(unittest.TestCase):
self.assertTrue(desc.fingerprint is not None)
self.assertTrue(desc.nickname is not None)
+ unrecognized_lines = desc.get_unrecognized_lines()
+
+ if unrecognized_lines:
+ self.fail("Unrecognized descriptor content: %s" % unrecognized_lines)
+
count += 1
if count > 10:
break
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index de079e4..7095f5a 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -337,7 +337,7 @@ class TestControl(unittest.TestCase):
nickname = "Beaver"
fingerprint = "/96bKo4soysolMgKn5Hex2nyFSY"
desc = "r %s %s u5lTXJKGsLKufRLnSyVqT7TdGYw 2012-12-30 22:02:49 77.223.43.54 9001 0\ns Fast Named Running Stable Valid\nw Bandwidth=75" % (nickname, fingerprint)
- router = stem.descriptor.router_status_entry.RouterStatusEntryV2(desc)
+ router = stem.descriptor.router_status_entry.RouterStatusEntryV3(desc)
# always return the same router status entry
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits