Dns
DNS resolution module.
Resolves hostnames to IPv4 addresses via the platform's getaddrinfo(3). Results reflect the system's resolver configuration (e.g. /etc/hosts, /etc/resolv.conf, mDNS, and any configured search domains).
Public API: Dns.resolve(host) : Result(List(String), DnsError) Dns.resolve_one(host) : Result(String, DnsError) Dns.is_ip(s) : Bool Dns.error_message(e) : String
Types
Functions
Return a human-readable description of a DnsError.
Return true if s looks like an IPv4 address (four dot-separated octets). Does not validate octet ranges.
Dns.is_ip("127.0.0.1") -- true
Dns.is_ip("example.com") -- falseResolve hostname to a list of IPv4 address strings. Returns Ok(addrs) where addrs is non-empty, or Err on failure.
match Dns.resolve("example.com") do
Ok(ips) -> List.head_opt(ips)
Err(e) -> panic(Dns.error_message(e))
end