I converted IPv6 addresses to a text representation and noticed behavior that I could not explain:
In[38]: socket.inet_ntop(socket.AF_INET6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x7f\x00\x00\x01')
Out[38]: '::ffff:127.0.0.1'
In[39]: socket.inet_ntop(socket.AF_INET6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x7f\x00\x00\x00')
Out[39]: '::ff:ffff:7f00:0'
I am surprised to see it ::ffff:127.0.0.1, I expect it to be ::ffff:7f00:0. Is this standard or at least generic? What IPv6 addresses are represented in this way? The Wikipedia article does not mention this at all. I'm confused.
source
share