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

addrinfo: fix address ordering #68

Merged
merged 1 commit into from
Jun 23, 2023
Merged

Conversation

achille-roussel
Copy link
Contributor

This change introduces a bit more determinism in the behavior of the name resolver.

There were a few issues:

  • we were using the capacity of the results slice instead of its length to determine how many addresses may be returned
  • we sliced the ip list to the first N elements before checking for the hints, which could result in only having results of the wrong address family (then failing name resolution)

I also added a partial sort of the results so that we put the AF_INET addresses first when they are mixed with AF_INET6 due to the hint being AF_UNSPEC, this helps keep the behavior deterministic; for example, if the client uses the first address that it is returned, it doesn't result in sometimes connecting to an IPv4 and sometimes an IPv6.

Signed-off-by: Achille Roussel <[email protected]>
@achille-roussel achille-roussel merged commit e567e17 into main Jun 23, 2023
2 checks passed
@achille-roussel achille-roussel deleted the fix-addrinfo-ordering branch June 23, 2023 21:10
achille-roussel added a commit that referenced this pull request Jun 23, 2023
Follow up to #68, the
address family was never set.

Signed-off-by: Achille Roussel <[email protected]>
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