I am running python on the iOS App Pythonista 3. When I try to get an IPv6 address it ends up returning bytes rather than a formatted address. Right now I am trying to find a way to either get the address properly without bytes, or to find a way to make the bytes become the address. Here is the code I ran to get the address:
def getIPv6Addr(input):
return socket.getaddrinfo(input, None, socket.AF_INET6)
and here was the output:
[(30, 2, 17, '', (30, '\x00\x00\x00\x00\x00\x00&\x07\xf8\xb0@\x00\x08\x14')), (30, 1, 6, '', (30, '\x00\x00\x00\x00\x00\x00&\x07\xf8\xb0@\x00\x08\x14'))]
Edit: The alternative solution is to find what type of encoding is being used to turn this data into bytes.
What Makes:
2607:f8b0:4000:814::200e
become
\x00\x00\x00\x00\x00\x00&\x07\xf8\xb0@\x00\x08\x14
You can use the ipaddress module that is included with python. Just pass the bytes to the constructor of ipaddress.IPv6Address and you'll get an object representing the address and giving you lots of possibilities to print and manipulate it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With