Skip to main content

Module dns

Module dns 

Source
Expand description

DNS resolution for Seq.

Resolves hostnames to IP-address strings via libc’s getaddrinfo, offloaded onto a dedicated OS-thread pool so may-carrier threads never park on the syscall. Inherits all platform-correct resolution behaviour (/etc/hosts, systemd-resolved, VPN/corp DNS, mDNS) for free.

A small TTL cache collapses fanout to the same host. Cache and worker pool are process-global and lazy-initialised on first call.

§Surface

net.dns.resolve ( String -- List Bool ) returns a list of IP-string representations. On unresolvable name or empty result, pushes (empty-list, false).

§Fanout collapsing

Both sequential and concurrent fanout collapse to a single getaddrinfo. The TTL cache (see CACHE) catches the sequential case. The in-flight map (see IN_FLIGHT) catches the concurrent case: when N strands race to resolve the same uncached host, the first to arrive enqueues exactly one worker job and the others attach their reply channels to the in-flight entry. When the worker returns, it writes the cache and fans the result out to every attached channel. Late arrivers that come in after the fanout pop see the freshly-written cache and short-circuit without ever touching the in-flight map.

Functions§

patch_seq_dns_resolve
Resolve a hostname to a list of IP-address strings.
resolve
Resolve a hostname to a list of IP-address strings.
resolve_to_ips
Resolve a hostname to a Vec<IpAddr>, with an IP-literal fast path.