Expand description
Networking utilities - Happy Eyeballs endpoint resolution.
When a URL contains localhost, the OS may resolve it to both [::1] (IPv6)
and 127.0.0.1 (IPv4). If the server only listens on one protocol, the client
stalls for ~2 s on every request while the first SYN times out. This module
races a TCP connect to both addresses in parallel and rewrites the URL to use
whichever responds first - eliminating that per-request penalty.
Functions§
- resolve_
localhost - If
endpointcontainslocalhost, race IPv4 vs IPv6 TCP connects and return a rewritten URL using the winning literal address. If both fail (or the URL doesn’t uselocalhost), the original endpoint is returned unchanged.