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

Conversation

Projects
None yet
2 participants
@nateberkopec
Copy link
Member

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

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link
Member Author

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 left a comment

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

@nateberkopec

This comment has been minimized.

Copy link
Member Author

nateberkopec commented Jun 4, 2017

Looks like it's in 1.9.3, so no.

@nateberkopec

This comment has been minimized.

Copy link
Member Author

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

@nateberkopec nateberkopec merged commit 4db1dcd into master Aug 3, 2017

1 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@nateberkopec nateberkopec deleted the localhost_addr branch Nov 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment