commit 823aa3a239bb09f8fbcbc64b6d22c2605150ce77 Author: Isis Lovecruft isis@torproject.org Date: Sat Dec 7 04:34:52 2013 +0000
Do not check IP validity in parse.addr.isIPv4() and parse.addr.isIPv6().
We only want to know if it is IPv4 or IPv6, *not* if it conforms to all kinds of crazy routing RFCs. --- lib/bridgedb/parse/addr.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/bridgedb/parse/addr.py b/lib/bridgedb/parse/addr.py index 6d2d51b..10c5b25 100644 --- a/lib/bridgedb/parse/addr.py +++ b/lib/bridgedb/parse/addr.py @@ -188,8 +188,12 @@ def _isIPv(version, ip): :rtype: boolean :returns: ``True``, if the address is an IPv4 address. """ - ip = isIPAddress(ip, compressed=False) - if ip and (ip.version == version): + try: + ip = ipaddr.IPAddress(ip, version=version) + except ipaddr.AddressValueError: + logging.debug("Address %s seems not to be IPv%d." % (ip, version)) + return False + else: return True return False
tor-commits@lists.torproject.org