Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Net::HTTP tests ensure local & remote hosts are same addr family #9698

Conversation

KJTsanaktsidis
Copy link
Contributor

  • When making connections wiht TCPSocket.new and friends, we resolve the passed-in hostname with AI_ADDRCONFIG.
  • AI_ADDRCONFIG means (in practice) "do not make AAAA queries or return any IPv6 addresses unless this machine has a network interface with an IPv6 address".
  • The loopback adapter does NOT count as "a network interface with an IPv6 address" for this check; your machine must have some other, non loopback address.

This causes issues with the Net::HTTP tests which set the local_host to connect from. This obviously needs to have the same address family as the host to connect to. However, we call Addrinfo.tcp('localhost')
without AI_ADDRCONFIG to set this, which means it might be ::1 even
in circumstances where the lookup done on the hostname to connect to (also 'localhost') returns 127.0.0.1.

Fix this by passing a hostname into local_host=, not an address; the hostname will be resolved with the same address family used for connecting.

https://bugs.ruby-lang.org/issues/20208

* When making connections wiht TCPSocket.new and friends, we resolve the
  passed-in hostname with AI_ADDRCONFIG.
* AI_ADDRCONFIG means (in practice) "do not make AAAA queries or return
  any IPv6 addresses unless this machine has a network interface with an
  IPv6 address".
* The loopback adapter does _NOT_ count as "a network interface with an
  IPv6 address" for this check; your machine must have some _other_, non
  loopback address.

This causes issues with the Net::HTTP tests which set the local_host to
connect _from_. This obviously needs to have the same address family as
the host to connect _to_. However, we call Addrinfo.tcp('localhost')
 _without_ AI_ADDRCONFIG to set this, which means it might be `::1` even
in circumstances where the lookup done on the hostname to connect _to_
(also 'localhost') returns `127.0.0.1`.

Fix this by passing a hostname into `local_host=`, not an address; the
hostname will be resolved with the same address family used for
connecting.

[Bug #20208]
@KJTsanaktsidis
Copy link
Contributor Author

We decided to just revert the whole AI_ADDRCONFIG thing instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant