Closed adrian-nicolau closed 8 years ago
IP addresses are currently compared as strings. It seems that proper approach is to use a module for IP address operations. Python 3 contains ipaddress module in its standard library. It has been backported to Python 2.7.
https://pypi.python.org/pypi/py2-ipaddress
I asked Twisted devs if there is some other suggested solution.
Fix added - version 0.2.0 . New dependency: py2-ipaddress
Suppose we try to send a request to fd55:976b:4680:0000:0000:00ff:fe00:0400, which is not a canonical representation (RFC 5952), yet a valid IPv6 address. The response is not recognized because the address is in canonical form (fd55:976b:4680::ff:fe00:400). Even though fd55:976b:4680:0000:0000:00ff:fe00:0400 and fd55:976b:4680::ff:fe00:400 are not equal as strings, they are the same IPv6 address.
Snippet:
2016-04-14 14:23:12+0300 [-] Sending request - Token: 0000cea2, Host: fd55:976b:4680:0000:0000:00ff:fe00:0400, Port: 19789 [...] 2016-04-14 14:23:12+0300 [Coap (UDP)] Received Response, token: 0000cea2, host: fd55:976b:4680::ff:fe00:400, port: 19789 2016-04-14 14:23:12+0300 [Coap (UDP)] Response not recognized - sending RST.