a package:dns

IPv4 address
Generator of QueryControls that adjusts the AD bit.
>>> adFlag FlagSet
ad:1
RRs holding additional information
RRs answering the question
AA (Authoritative Answer) bit - this bit is valid in responses, and specifies that the responding name server is an authority for the domain name in question section.
AD (Authenticated Data) bit - (RFC4035, Section 3.2.3).
RRs pointing toward an authority
IPv6 Address
A request for all records the server/cache has available
Zone transfer (RFC5936)
Type for resource records in the additional section.
Type alias for resource records in the answer section.
Type alias for resource records in the answer section.
Decode an input buffer containing a single encoded DNS message. If the input buffer has excess content beyond the end of the message an error is returned. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted at the supplied epoch time.
Decode a buffer containing multiple encoded DNS messages each preceded by a 16-bit length in network byte order. Any left-over bytes of a partial message after the last complete message are returned as the second element of the result tuple. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted based on a nominal time in the year 2078 chosen to give correct dates for DNS timestamps over a 136 year time range from the date the root zone was signed on the 15th of July 2010 until the 21st of August in 2146. Outside this date range the output is off by some non-zero multiple 2^32 seconds.
Decode a buffer containing multiple encoded DNS messages each preceded by a 16-bit length in network byte order. Any left-over bytes of a partial message after the last complete message are returned as the second element of the result tuple. DNS circle-arithmetic timestamps (e.g. in RRSIG records) are interpreted at the supplied epoch time.
Compose a response with a single IPv4 RRset. If the query had an EDNS pseudo-header, a suitable EDNS pseudo-header must be added to the response message, or else a FormatErr response must be sent. The response TTL defaults to 300 seconds, and should be updated (to the same value across all the RRs) if some other TTL value is more appropriate.
Compose a response with a single IPv6 RRset. If the query had an EDNS pseudo-header, a suitable EDNS pseudo-header must be added to the response message, or else a FormatErr response must be sent. The response TTL defaults to 300 seconds, and should be updated (to the same value across all the RRs) if some other TTL value is more appropriate.
Send one or more encoded DNSMessage buffers over TCP, each allready encapsulated with an explicit length prefix (perhaps via encodeVC) and then concatenated into a single buffer. DO NOT use sendAll with UDP.
Look up all 'A' records for the given hostname. A straightforward example:
>>> rs <- makeResolvSeed defaultResolvConf

>>> withResolver rs $ \resolver -> lookupA resolver "192.0.2.1.nip.io"
Right [192.0.2.1]
This function will also follow a CNAME and resolve its target if one exists for the queried hostname:
>>> rs2 <- makeResolvSeed defaultResolvConf

>>> withResolver rs2 $ \resolver -> lookupA resolver "www.kame.net"
Right [210.155.141.200]
Look up all (IPv6) 'AAAA' records for the given hostname. Examples:
>>> rs <- makeResolvSeed defaultResolvConf

>>> withResolver rs $ \resolver -> lookupAAAA resolver "www.wide.ad.jp"
Right [2001:200:0:180c:20c:29ff:fec9:9d61]
Look up all 'MX' records for the given hostname, and then resolve their hostnames to IPv6 addresses by calling lookupAAAA. The priorities are not retained.
Look up all 'MX' records for the given hostname, and then resolve their hostnames to IPv4 addresses by calling lookupA. The priorities are not retained. Examples:
>>> import Data.List (sort)

>>> rs <- makeResolvSeed defaultResolvConf

>>> ips <- withResolver rs $ \resolver -> lookupAviaMX resolver "wide.ad.jp"

>>> fmap sort ips
Right [203.178.136.30]
Since there is more than one result, it is necessary to sort the list in order to check for equality.
Look up all 'NS' records for the given hostname. The results are taken from the AUTHORITY section of the response and not the usual ANSWER (use lookupNS for that). For details, see e.g. http://www.zytrax.com/books/dns/ch15/. There will typically be more than one name server for a domain. It is therefore extra important to sort the results if you prefer them to be at all deterministic. For an example, we can look up the nameservers for "example.com" from one of the root servers, a.gtld-servers.net, the IP address of which was found beforehand:
>>> import Data.List (sort)

>>> let ri = RCHostName "192.5.6.30" -- a.gtld-servers.net

>>> let rc = defaultResolvConf { resolvInfo = ri }

>>> rs <- makeResolvSeed rc

>>> ns <- withResolver rs $ \resolver -> lookupNSAuth resolver "example.com"

>>> fmap sort ns
Right ["a.iana-servers.net.","b.iana-servers.net."]
Look up the 'SOA' record for the given domain. The result 7-tuple consists of the 'mname', 'rname', 'serial', 'refresh', 'retry', 'expire' and 'minimum' fields of the SOA record. An @ separator is used between the first and second labels of the 'rname' field. Since 'rname' is an email address, it often contains periods within its first label. Presently, the trailing period is not removed from the domain part of the 'rname', but this may change in the future. Users should be prepared to remove any trailing period before using the 'rname` as a contact email address.
>>> rs <- makeResolvSeed defaultResolvConf

>>> soa <- withResolver rs $ \resolver -> lookupSOA resolver "mew.org"

>>> map (\ (mn, rn, _, _, _, _, _) -> (mn, rn)) <$> soa
Right [("ns1.mew.org.","kazu@mew.org.")]