commit c01a9cda4e7699c7f4bd642c8e81ed45aab7a29b
Author: Damian Johnson <[email protected]>
Date: Sun Jan 10 18:41:32 2016 -0800
Simplify ipv6 handling for router descriptors
Oops, very similar to another function we simplified in commit 3c7ea19. No
need
to keep the old bracket handling bit.
---
stem/descriptor/router_status_entry.py | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/stem/descriptor/router_status_entry.py
b/stem/descriptor/router_status_entry.py
index b3cd637..a30ad0f 100644
--- a/stem/descriptor/router_status_entry.py
+++ b/stem/descriptor/router_status_entry.py
@@ -166,17 +166,12 @@ def _parse_a_line(descriptor, entries):
raise ValueError("%s 'a' line must be of the form '[address]:[ports]': a
%s" % (descriptor._name(), value))
address, port = value.rsplit(':', 1)
- is_ipv6 = address.startswith('[') and address.endswith(']')
- if is_ipv6:
- address = address[1:-1] # remove brackets
-
- if not ((not is_ipv6 and
stem.util.connection.is_valid_ipv4_address(address)) or
- (is_ipv6 and stem.util.connection.is_valid_ipv6_address(address,
allow_brackets = True))):
+ if not stem.util.connection.is_valid_ipv4_address(address) and not
stem.util.connection.is_valid_ipv6_address(address, allow_brackets = True):
raise ValueError("%s 'a' line must start with an IPv6 address: a %s" %
(descriptor._name(), value))
if stem.util.connection.is_valid_port(port):
- or_addresses.append((address.lstrip('[').rstrip(']'), int(port),
is_ipv6))
+ or_addresses.append((address.lstrip('[').rstrip(']'), int(port),
stem.util.connection.is_valid_ipv6_address(address, allow_brackets = True)))
else:
raise ValueError("%s 'a' line had an invalid port (%s): a %s" %
(descriptor._name(), port, value))
_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits