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

Sockets: fix getipaddr/getipaddrs documentation, add islinklocaladdr function #34300

Merged
merged 2 commits into from
Jan 17, 2020

Conversation

mgkuhn
Copy link
Contributor

@mgkuhn mgkuhn commented Jan 7, 2020

Fix getipaddr/getipaddrs documentation:

  • resolved IPv4/IPv6 confusion, e.g. getipaddrs() does not return only IPv4

  • more realistic example addresses (not just non-routeable IPv6 link-local addresses)

  • example addresses taken from address ranges reserved for documentation https://en.wikipedia.org/wiki/Reserved_IP_addresses

Add Sockets.islinklocaladdr:

IPv6 interfaces always have an fe80::/10 link-local address configured, which is also reported by getipaddrs(). However, typical application servers are not reachable under their link-local address, therefore this convenience function helps users of getipaddrs() to filter out such addresses with filter(!islinklocaladdr, getipaddrs()).

This commit also adds a "See also" hint to make potential users of getaddrs aware that in applications where a server process has been started remotely via ssh the address found in split(ENV["SSH_CONNECTION"], ' ')[3] can be a preferable alternative source for an IP address under which this server is reachable, namely the very IP address that ssh has already used successfully to get here.

- resolved IPv4/IPv6 confusion, e.g. getipaddrs() does _not_ return only IPv4

- more realistic example addresses

- example addresses taken from address ranges reserved for documentation
  https://en.wikipedia.org/wiki/Reserved_IP_addresses
"""
function islinklocaladdr(addr::IPv4)
# RFC 3927
return addr.host &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use parens around the & I think. Looks odd otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, parentheses now added in rebased commit b62e10c.

IPv6 interfaces always have a link-local address configured, which is
also reported by getipaddrs(). However, typical application servers
are not reachable under their link-local address, therefore this
convenience function helps users of getipaddrs() to filter
out such addresses with `filter(!islinklocaladdr, getipaddrs())`.

This commits also adds a "See also" hint that in applications where
a server process has been started remotely via ssh that
`split(ENV["SSH_CONNECTION"], ' ')[3]` can be a preferable
alternative source for the IP address under which this server
is reachable (namely the address that ssh has already used
successfully to get here).
@mgkuhn
Copy link
Contributor Author

mgkuhn commented Jan 8, 2020

@Keno Ready to be merged? (the buildbot/tester_win32 failure seems unrelated to this PR and I don't have permission to press the Rebuild button on https://build.julialang.org/#/builders/65/builds/6777: "Cannot rebuild: you need to have role 'JuliaLang'", how does one get this?)

@Keno Keno merged commit 250aecc into JuliaLang:master Jan 17, 2020
@mgkuhn mgkuhn deleted the ipaddrs branch March 19, 2020 18:59
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
…function (#34300)

* fix getipaddr/getipaddrs documentation

- resolved IPv4/IPv6 confusion, e.g. getipaddrs() does _not_ return only IPv4

- more realistic example addresses

- example addresses taken from address ranges reserved for documentation
  https://en.wikipedia.org/wiki/Reserved_IP_addresses

* add Sockets.islinklocaladdr

IPv6 interfaces always have a link-local address configured, which is
also reported by getipaddrs(). However, typical application servers
are not reachable under their link-local address, therefore this
convenience function helps users of getipaddrs() to filter
out such addresses with `filter(!islinklocaladdr, getipaddrs())`.

This commits also adds a "See also" hint that in applications where
a server process has been started remotely via ssh that
`split(ENV["SSH_CONNECTION"], ' ')[3]` can be a preferable
alternative source for the IP address under which this server
is reachable (namely the address that ssh has already used
successfully to get here).
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

Successfully merging this pull request may close these issues.

3 participants