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

gethostbyname "localhost" has no ipv6 address #4333

Open
andrew-aladev opened this issue Nov 23, 2016 · 2 comments
Open

gethostbyname "localhost" has no ipv6 address #4333

andrew-aladev opened this issue Nov 23, 2016 · 2 comments

Comments

@andrew-aladev
Copy link

Environment

  • jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM 25.101-b13 on 1.8.0_101-b13 +jit [linux-x86_64]
  • JRUBY_OPTS="-J-Djava.net.preferIPv4Stack=false"
  • Installed or activated gems: puma-3.6.2-java

Puma uses TCPSocket.gethostbyname to receive a list of localhost addresses. So this issue is important for puma.

require "socket"
TCPSocket.gethostbyname "localhost"

Expected Behavior

ruby-2.3.1 will provide:

["localhost", [], 10, "::1", "127.0.0.1"]

Actual Behavior

jruby-9.1.6.0 will provide

["127.0.0.1", [], 2, "127.0.0.1"]

Please make gethostbyname compatible with the recent mri ruby.

@olleolleolle
Copy link
Member

olleolleolle commented Dec 1, 2016

Link to current implementation: org/jruby/ext/socket/RubyTCPSocket.java

In MRI trunk:

Here was a comment that taught me a thing:

 * Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc.
 * If you need local IP address, use Socket.ip_address_list.

Workaround?: Trying it, I noted that Socket.ip_address_list produces Addrinfo objects. Can those be used by puma's localhost_addresses to synthesize that list?

@andrew-aladev
Copy link
Author

Sure. This solution is ok. I will create an issue for puma.

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

No branches or pull requests

2 participants