Standard library · The network
net/dns
Imported as import "net/dns" as dns, its names are then dns.…. Every signature below is the one the checker infers.
Functions
fn lookup(name: Str) -> Result(List(Str), Str)
Every address the name has, IPv4 addresses first and then IPv6, or why there are none.
res_map(dns.lookup("localhost"), \addrs -> any(addrs, \a -> a == "127.0.0.1")) # => Ok(true) res_map(dns.lookup("no.such.host.invalid"), \addrs -> len(addrs)) # => Err(`no.such.host.invalid` is not a name the resolver knows)
fn ipv4(name: Str) -> Option(Str)
The first IPv4 address, which is what tcp_connect and udp.send_to take.
dns.ipv4("localhost") # => Some(127.0.0.1)
fn is_ipv4(s: Str) -> Bool
Four numbers of at most three digits, each below 256, with dots between.
dns.is_ipv4("192.168.0.1") # => true dns.is_ipv4("256.1.1.1") # => false dns.is_ipv4("::1") # => false
Tests
test_localhost_and_literalstest_an_unknown_name