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

[tor-commits] [stem/master] Recognize platform line for node-Tor relays



commit 1f2ea0f2eb5ab19d272b72e022bd5f0266662780
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Feb 22 07:11:43 2014 -0800

    Recognize platform line for node-Tor relays
    
    We have a few relays in the wild running node-Tor, a JS counterpart for tor...
    
      https://github.com/Ayms/node-Tor
    
    These relays have a 'node-' prefix on their platform lines. For instance...
    
      'platform node-Tor 0.1.0 on Linux x86_64'
      https://atlas.torproject.org/#details/E0671CF9CB593F27CD389CD4DD819BF9448EA834
    
    Caught by sysrqb on...
    
      https://trac.torproject.org/11008
---
 stem/descriptor/server_descriptor.py      |    2 +-
 test/unit/descriptor/server_descriptor.py |   12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 5537de7..a88594b 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -440,7 +440,7 @@ class ServerDescriptor(Descriptor):
         # There's no guarantee that we'll be able to pick these out the
         # version, but might as well try to save our caller the effort.
 
-        platform_match = re.match("^Tor (\S*).* on (.*)$", value)
+        platform_match = re.match("^(?:node-)?Tor (\S*).* on (.*)$", value)
 
         if platform_match:
           version_str, self.operating_system = platform_match.groups()
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index b0af7cc..6308535 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -9,6 +9,7 @@ import unittest
 import stem.descriptor.server_descriptor
 import stem.exit_policy
 import stem.prereq
+import stem.version
 import stem.util.str_tools
 
 from stem.descriptor.server_descriptor import RelayDescriptor, BridgeDescriptor
@@ -143,6 +144,17 @@ class TestServerDescriptor(unittest.TestCase):
     desc = RelayDescriptor(desc_text, validate = False)
     self.assertEquals(b"", desc.platform)
 
+  @patch('stem.descriptor.server_descriptor.RelayDescriptor._verify_digest', Mock())
+  def test_platform_for_node_tor(self):
+    """
+    Parse a platform line belonging to a node-Tor relay.
+    """
+
+    desc = get_relay_server_descriptor({"platform": "node-Tor 0.1.0 on Linux x86_64"})
+    self.assertEquals(b"node-Tor 0.1.0 on Linux x86_64", desc.platform)
+    self.assertEquals(stem.version.Version("0.1.0"), desc.tor_version)
+    self.assertEquals("Linux x86_64", desc.operating_system)
+
   def test_protocols_no_circuit_versions(self):
     """
     Constructs with a protocols line without circuit versions.



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