Skip to content

Connect to IP literals using their own address family - #552

Merged
ericmj merged 2 commits into
mainfrom
ip-literal-address-family
Nov 17, 2026
Merged

ericmj merged 2 commits into
mainfrom
ip-literal-address-family

Conversation

@ericmj

@ericmj ericmj commented Nov 17, 2026

Copy link
Copy Markdown
Member

Connecting to an IPv6 literal such as "::1" without inet6: true always fails with :nxdomain, even when the port is listening, because :gen_tcp gets the default inet family and resolves the literal as a hostname. Callers hit this with URLs like http://[::1]:4000, since URI.parse/1 strips the brackets and Mint receives "::1". With inet6: true and the default inet4: true, a refused connection to "::1" returns :nxdomain from the IPv4 fallback instead of :econnrefused.

IP literals and IP tuples now connect once using their own family, and :inet6/:inet4 only apply to hostnames. TCP and SSL both get the change.

This replaces #546 by @dch, keeping their commit, so maintainers can push to the branch.

Co-authored-by: Dave Cottlehuber dch@skunkwerks.at

dch and others added 2 commits November 17, 2026 17:14
When the address was an IP literal, gen_tcp got the wrong family and
treated it as a hostname. Mint then returned :nxdomain from the IPv4
fallback instead of the real error, after an unneeded DNS lookup and
timeouts.

- connect to IPv6 literals over inet6 and IPv4 literals over inet,
  ignoring :inet6 and :inet4
- keep the inet6-then-inet4 fallback for hostnames
- apply the same change to TCP and SSL
Connect IP literals through one clause for both families, drop the
redundant is_tuple/1 guards, and remove the Unreleased changelog
section since the changelog is written at release time.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 328

Coverage increased (+0.09%) to 90.337%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: 2 uncovered changes across 2 files (19 of 21 lines covered, 90.48%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
lib/mint/core/transport/ssl.ex 7 6 85.71%
lib/mint/core/transport/tcp.ex 7 6 85.71%
Total (3 files) 21 19 90.48%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2049
Covered Lines: 1851
Line Coverage: 90.34%
Coverage Strength: 730.66 hits per line

💛 - Coveralls

@ericmj
ericmj merged commit 0c4d189 into main Nov 17, 2026
3 checks passed
@ericmj
ericmj deleted the ip-literal-address-family branch November 17, 2026 16:18
@ericmj

ericmj commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Thank you @dch!

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