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

Use Socket.ip_address_list to get loopback addresses #1318

Merged
merged 1 commit into from Aug 3, 2017
Merged

Conversation

@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Jun 3, 2017

This will fix #1167

See JRuby bug

Need some guidance from @evanphx here: is binder supposed to bind to only loopback interfaces by default (as I've done in this PR) or is it supposed to bind to linklocal addresses as well?

Here's what this method returned before (my machine, CRuby):

["::1", "fe80::1%lo0", "127.0.0.1"]

Now:

["127.0.0.1", "::1"]

Note the omission of an ipv6 link-local interface. The reason I removed it was that there are several other link-local interfaces on my machine which I don't think puma should bind to:

irb(main):013:0> Socket.ip_address_list.select do |addrinfo|
irb(main):014:1* addrinfo.ipv6_linklocal?
irb(main):015:1> end
=> [#<Addrinfo: fe80::1%lo0>, #<Addrinfo: fe80::4b:c017:51b5:cd33%en0>, #<Addrinfo: fe80::989b:30ff:fe14:9e01%awdl0>, #<Addrinfo: fe80::f16e:6368:16b5:ff60%utun0>]

@evanphx if you can clarify the intent here, I'll add a test.

@nateberkopec
Copy link
Member Author

@nateberkopec nateberkopec commented Jun 3, 2017

Ah, I think I get it now. Linking #782.

@nateberkopec nateberkopec removed the request for review from evanphx Jun 3, 2017
@nateberkopec
Copy link
Member Author

@nateberkopec nateberkopec commented Jun 3, 2017

I'm also going to link #1022 here, because the original fix here caused that issue, maybe I can satisfy everyone.

@nateberkopec nateberkopec self-assigned this Jun 4, 2017
@evanphx evanphx self-requested a review Jun 4, 2017
@evanphx
evanphx approved these changes Jun 4, 2017
Copy link
Member

@evanphx evanphx left a comment

Looks good. When did Socket.ip_address_list show up? Do we need to be worried about ruby compat?

@nateberkopec
Copy link
Member Author

@nateberkopec nateberkopec commented Jun 4, 2017

Looks like it's in 1.9.3, so no.

@nateberkopec
Copy link
Member Author

@nateberkopec nateberkopec commented Jun 4, 2017

Also, JRuby returns the same result as CRuby does here, though it prints the full ipv6 address rather than the short ::1.

@nateberkopec nateberkopec force-pushed the localhost_addr branch from 1e8795a to d2e9d7d Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants