Repository navigation
TCP and SSL: treat an IP literal as an address, not a host name - #12
Open
dominicletz wants to merge 2 commits into
Open
dominicletz wants to merge 2 commits into
dominicletz wants to merge 2 commits into
Conversation
connect/3 turned every binary into a charlist and handed it to :gen_tcp.connect/4, which resolves it as a name in the socket's family. "::1" therefore came back :nxdomain on a socket nobody had declared :inet6, while a tuple carries its own family. Parse first, and fall back to a charlist only for what really is a host name. The @SPEC already announced :inet.ip_address(), which the code could not handle. It now says Socket.Address.t(), which it does.
connect/3 carried the same charlist conversion as Socket.TCP.connect/3, with the same effect: the literal went to the resolver instead of to the socket. Its test reads a failure rather than a success — no TLS server answers on the other end — because :nxdomain is what the resolution path returns and a handshake timeout is not.
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rebase of #8 onto current
master. The address-parser commit that #8 was stacked on already landed as #7, so it is not in this branch.Socket.TCP.connect/3andSocket.SSL.connect/3turned every binary into a charlist and handed it to the resolver in the socket's family."::1"therefore came back:nxdomainunless the caller had also passedversion: 6, while a tuple carries its own family. A literal is now parsed first ("::1","[::1]", or an IPv4 literal) and only a real host name is sent as a charlist. The@specofSocket.TCP.connect/3andconnect!/3now saysSocket.Address.t(), which is what the clauses accept.This is the base of the stack. Merge this first, then #13, then #11.
v6only) does not call this code. It is stacked here so the sharedtest/ipv6_test.exsstays one line of commits."::1"throughSocket.Web.connect!/3, which callsSocket.TCP.connect!/3. That test fails with:nxdomainuntil this lands.mix teston this branch is 20 tests, 0 failures (Elixir 1.14.0 / OTP 25).mix format --check-formattedpasses.A charlist literal such as
~c"::1"is still passed straight to the resolver. Binaries and tuples are the forms the tests cover, and a charlist did not matchconnect/3at all before this change.Note
Medium Risk
Changes shared connect entry points for TCP and SSL; hostname behavior is preserved for non-literals, but any caller relying on the old charlist-only binary path could see different IPv6 results.
Reviewed by Cursor Bugbot for commit c137c8d. Configure here.