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

[tor-commits] [stem/master] Dropping support for port lists in descriptors



commit dd220882e6c73863cc574ec4ba3833ee478314cb
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Mar 19 13:40:10 2013 -0700

    Dropping support for port lists in descriptors
    
    The 'or-address' and 'a' descriptors supported comma separated lists of ports.
    However, as per spec commit 99a9587 tor has never supported this, and the spec
    no longer includes this capability.
---
 stem/descriptor/router_status_entry.py      |   12 ++++--------
 stem/descriptor/server_descriptor.py        |   12 ++++--------
 test/unit/descriptor/router_status_entry.py |    6 +-----
 test/unit/descriptor/server_descriptor.py   |    4 +---
 4 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py
index 69b8fa2..e2579eb 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -531,7 +531,7 @@ def _parse_a_line(desc, value, validate):
 
     raise ValueError("%s 'a' line must be of the form '[address]:[ports]': a %s" % (desc._name(), value))
 
-  address, ports = value.rsplit(':', 1)
+  address, port = value.rsplit(':', 1)
   is_ipv6 = address.startswith("[") and address.endswith("]")
 
   if is_ipv6:
@@ -544,14 +544,10 @@ def _parse_a_line(desc, value, validate):
     else:
       raise ValueError("%s 'a' line must start with an IPv6 address: a %s" % (desc._name(), value))
 
-  for port in ports.split(','):
-    if not stem.util.connection.is_valid_port(port):
-      if not validate:
-        continue
-      else:
-        raise ValueError("%s 'a' line had an invalid port (%s): a %s" % (desc._name(), port, value))
-
+  if stem.util.connection.is_valid_port(port):
     desc.or_addresses.append((address, int(port), is_ipv6))
+  elif validate:
+    raise ValueError("%s 'a' line had an invalid port (%s): a %s" % (desc._name(), port, value))
 
 
 def _parse_s_line(desc, value, validate):
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index bb7baa9..362437f 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -517,7 +517,7 @@ class ServerDescriptor(stem.descriptor.Descriptor):
             else:
               raise ValueError("or-address line missing a colon: %s" % line)
 
-          address, ports = entry.rsplit(':', 1)
+          address, port = entry.rsplit(':', 1)
           is_ipv6 = address.startswith("[") and address.endswith("]")
 
           if is_ipv6:
@@ -530,14 +530,10 @@ class ServerDescriptor(stem.descriptor.Descriptor):
             else:
               raise ValueError("or-address line has a malformed address: %s" % line)
 
-          for port in ports.split(","):
-            if not stem.util.connection.is_valid_port(port):
-              if not validate:
-                continue
-              else:
-                raise ValueError("or-address line has malformed ports: %s" % line)
-
+          if stem.util.connection.is_valid_port(port):
             self.or_addresses.append((address, int(port), is_ipv6))
+          elif validate:
+            raise ValueError("or-address line has a malformed port: %s" % line)
       elif keyword in ("read-history", "write-history"):
         try:
           timestamp, interval, remainder = \
diff --git a/test/unit/descriptor/router_status_entry.py b/test/unit/descriptor/router_status_entry.py
index b61f5e8..a97153a 100644
--- a/test/unit/descriptor/router_status_entry.py
+++ b/test/unit/descriptor/router_status_entry.py
@@ -315,9 +315,6 @@ class TestRouterStatusEntry(unittest.TestCase):
     test_values = {
       "[2607:fcd0:daaa:101::602c:bd62]:443": [
         ('2607:fcd0:daaa:101::602c:bd62', 443, True)],
-      "[2607:fcd0:daaa:101::602c:bd62]:80,443": [
-        ('2607:fcd0:daaa:101::602c:bd62', 80, True),
-        ('2607:fcd0:daaa:101::602c:bd62', 443, True)]
     }
 
     for a_line, expected in test_values.items():
@@ -327,11 +324,10 @@ class TestRouterStatusEntry(unittest.TestCase):
     # includes multiple 'a' lines
 
     content = get_router_status_entry_v3(content = True)
-    content += "\na [2607:fcd0:daaa:101::602c:bd62]:80,443"
+    content += "\na [2607:fcd0:daaa:101::602c:bd62]:443"
     content += "\na [1148:fcd0:daaa:101::602c:bd62]:80"
 
     expected = [
-      ('2607:fcd0:daaa:101::602c:bd62', 80, True),
       ('2607:fcd0:daaa:101::602c:bd62', 443, True),
       ('1148:fcd0:daaa:101::602c:bd62', 80, True),
     ]
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 3da01b5..ad62444 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -381,13 +381,11 @@ class TestServerDescriptor(unittest.TestCase):
     """
 
     desc_text = "\n".join((get_bridge_server_descriptor(content = True),
-                          "or-address 10.45.227.253:9001,9005,80",
+                          "or-address 10.45.227.253:9001",
                           "or-address [fd9f:2e19:3bcf::02:9970]:443"))
 
     expected_or_addresses = [
       ("10.45.227.253", 9001, False),
-      ("10.45.227.253", 9005, False),
-      ("10.45.227.253", 80, False),
       ("fd9f:2e19:3bcf::02:9970", 443, True),
     ]
 



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