Net.DNS
module Net.DNS
Typed DNS lookup with explicit resolver ownership and bounded caching.
using Net.DNS
let resolver = Resolver.system.try
let name = Name.parse("example.test").try
let addresses = resolver.addresses(name).try
resolver.close
record Name
A validated DNS name with caller-facing and IDNA ASCII spellings.
Fields
type RecordType
Record families supported by Resolver.lookup.
Variants
AAAAACNAMEMXTXTSRVPTR
type DNSSECStatus
DNSSEC state reported by the underlying resolver. Kex does not independently validate DNSSEC and therefore commonly reports Indeterminate.
Variants
SecureInsecureBogusIndeterminate
type DNSRecord
Typed DNS resource records, preserving MX/SRV priorities and TXT chunks.
Variants
AddressRecord(Net.IP.Address)CanonicalName(Name)MailExchange(Integer, Name)TextRecord([String])ServiceRecord(Integer, Integer, Net.Port, Name)PointerRecord(Name)
record LookupResponse
Records and the reported DNSSEC state from one lookup.
Fields
records[DNSRecord]dnssecDNSSECStatus
record CacheOptions
Bounds for a resolver-owned positive and negative cache.
Fields
record Nameserver
One DNS server used by a custom resolver.
Fields
addressNet.IP.AddressportNet.Port
record ResolverOptions
Isolated resolver configuration. An empty search list only queries the name as written; search domains are tried in order for single-label names.
Fields
cacheCacheOptionsoptionalnameservers[Nameserver]search[Name]optionalretriesIntegeroptionaltimeoutDurationoptional
record CacheStatistics
Lifetime cache counters. clear empties entries but keeps these counters.
Fields
type Resolver
An opaque, process-safe resolver that owns its cache.
Methods
addresses
addresses(name: Name) -> Result<[Net.IP.Address], NetError>
Resolves AAAA and A records, returning IPv6 addresses first.
Parameters
name- the validated hostname
Returns addresses or Resolve
Examples
+resolver.addresses(Name.parse("example.test").try).try+
lookup
lookup(kind: RecordType, name: Name) -> Result<LookupResponse, NetError>
Looks up one supported resource-record family.
Parameters
kind- the requested family
name- the validated owner name
Returns typed records or Resolve
module Net.DNS.Name
module Net.DNS.Resolver
system
system(cache: CacheOptions) -> Result<Resolver, NetError>
Opens a resolver using system configuration and default cache bounds.
Returns a resolver handle
Examples
+Resolver.system.try+
custom
custom(options: ResolverOptions) -> Result<Resolver, NetError>
Opens an isolated resolver with typed nameservers and query bounds.
Parameters
options- nameservers, search domains, retry count,
Returns a resolver, or Parse
Examples
+Resolver.custom(ResolverOptions { nameservers: [Nameserver { address: Net.IP.Address.parse("127.0.0.1").try, port: Net.Port.from(53).try }], timeout: 100.milliseconds }).try+