Comment 5 for bug 1604608

Revision history for this message
LaMont Jones (lamont) wrote :

What is not addressed by this patch is that twisted assumes that if it is given a hostname, then the user clearly means IPv4. The web client setup is not in the correct order, it should be:
1) resolve the hostname
2) iterate through the available IP addresses (probably preferring ipv6, like the rest of linux), trying each one until success, or end-of-list
2a) create the AF_INET/AF_INET6 socket based on the address family of the current trial IP.
2b) connect.

Today, it creates the socket based on the name it's given (ipv4 address, ipv6 address, or "huh... hostname, let's try ipv4") and then resolves it.

The other option would be to create an AF_INET6 socket, and if it turns out that it's an IPv4 address, change it to the compatible ipv6 address of "::ffff:192.168.1.1" or such. Note that if the app then calls getsockname() on the socket, it will see the ipv6-form, and may be confused.