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

[tor-commits] [stem/master] Expand IPv6 addresses from the proc module



commit a06302ce5547798d5846c0e99fabccc6640c4a1b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Mar 27 13:40:44 2016 -0700

    Expand IPv6 addresses from the proc module
    
    Sebastian's running into unit test failures because the socket module gives him
    a different but equivalent address..
    
      https://trac.torproject.org/projects/tor/ticket/18659
    
    Normalizing addresses the module gives us.
---
 stem/util/proc.py      |  2 +-
 test/unit/util/proc.py | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/stem/util/proc.py b/stem/util/proc.py
index a0ceb8b..2897242 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -475,7 +475,7 @@ def _decode_proc_address_encoding(addr, is_ipv6):
 
       ip = b''.join(inverted)
 
-    ip = socket.inet_ntop(socket.AF_INET6, base64.b16decode(ip))
+    ip = stem.util.connection.expand_ipv6_address(socket.inet_ntop(socket.AF_INET6, base64.b16decode(ip)))
 
   return (ip, port)
 
diff --git a/test/unit/util/proc.py b/test/unit/util/proc.py
index e8858f1..72b7131 100644
--- a/test/unit/util/proc.py
+++ b/test/unit/util/proc.py
@@ -265,8 +265,8 @@ class TestProc(unittest.TestCase):
     }[param]
 
     expected_results = [
-      Connection('2a01:4f8:190:514a::2', 443, '2001:638:a000:4140::ffff:189', 40435, 'tcp', True),
-      Connection('2a01:4f8:190:514a::2', 443, '2001:858:2:2:aabb:0:563b:1526', 44469, 'tcp', True),
+      Connection('2a01:04f8:0190:514a:0000:0000:0000:0002', 443, '2001:0638:a000:4140:0000:0000:ffff:0189', 40435, 'tcp', True),
+      Connection('2a01:04f8:0190:514a:0000:0000:0000:0002', 443, '2001:0858:0002:0002:aabb:0000:563b:1526', 44469, 'tcp', True),
     ]
 
     self.assertEqual(expected_results, proc.connections(pid = pid))
@@ -293,9 +293,9 @@ class TestProc(unittest.TestCase):
     }[param]
 
     expected_results = [
-      Connection('::ffff:5.9.158.75', 5222, '::ffff:78.54.134.33', 38330, 'tcp', True),
-      Connection('2a01:4f8:190:514a::2', 5269, '2001:6f8:126f:11::26', 50594, 'tcp', True),
-      Connection('::ffff:5.9.158.75', 5222, '::ffff:78.54.134.33', 38174, 'tcp', True),
+      Connection('0000:0000:0000:0000:0000:ffff:0509:9e4b', 5222, '0000:0000:0000:0000:0000:ffff:4e36:8621', 38330, 'tcp', True),
+      Connection('2a01:04f8:0190:514a:0000:0000:0000:0002', 5269, '2001:06f8:126f:0011:0000:0000:0000:0026', 50594, 'tcp', True),
+      Connection('0000:0000:0000:0000:0000:ffff:0509:9e4b', 5222, '0000:0000:0000:0000:0000:ffff:4e36:8621', 38174, 'tcp', True),
     ]
 
     self.assertEqual(expected_results, proc.connections(user = 'me'))

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