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

[tor-commits] [bridgedb/master] Change Dist.uniformMap() to truncated IPv6 addresses to their /32.



commit c91def00b30be2ae130c9884a58bb700e093afb4
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Tue Mar 31 12:21:00 2015 +0000

    Change Dist.uniformMap() to truncated IPv6 addresses to their /32.
    
     * FIXES #15522: https://bugs.torproject.org/15522
---
 lib/bridgedb/Dist.py |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/bridgedb/Dist.py b/lib/bridgedb/Dist.py
index 466db84..6bb41b9 100644
--- a/lib/bridgedb/Dist.py
+++ b/lib/bridgedb/Dist.py
@@ -49,7 +49,7 @@ class EmailRequestedKey(Exception):
 def uniformMap(ip):
     """Map an IP to an arbitrary 'area' string, such that any two IPv4
     addresses in the same ``/16`` subnet, or any two IPv6 addresses in the
-    same ``/64`` subnet, get the same string.
+    same ``/32`` subnet, get the same string.
 
     >>> from bridgedb import Dist
     >>> Dist.uniformMap('1.2.3.4')
@@ -57,9 +57,9 @@ def uniformMap(ip):
     >>> Dist.uniformMap('1.2.211.154')
     '1.2.0.0/16'
     >>> Dist.uniformMap('2001:f::bc1:b13:2808')
-    '2001:f::/64'
+    '2001:f::/32'
     >>> Dist.uniformMap('2a00:c98:2030:a020:2::42')
-    '2a00:c98:2030:a020::/64'
+    '2a00:c98::/32'
 
     :param str ip: A string representing an IPv4 or IPv6 address.
     :rtype: str
@@ -71,8 +71,8 @@ def uniformMap(ip):
     # in a hashring.
     address = ipaddr.IPAddress(ip)
     if address.version == 6:
-        truncated = ':'.join(address.exploded.split(':')[:4])
-        subnet = str(ipaddr.IPv6Network(truncated + "::/64"))
+        truncated = ':'.join(address.exploded.split(':')[:2])
+        subnet = str(ipaddr.IPv6Network(truncated + "::/32"))
         return subnet
     else:
         truncated = '.'.join(address.exploded.split('.')[:2])



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