Sockets: fix getipaddr/getipaddrs documentation, add islinklocaladdr function #34300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix
getipaddr
/getipaddrs
documentation:resolved IPv4/IPv6 confusion, e.g.
getipaddrs()
does not return only IPv4more 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 insplit(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.