[      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ None0Raw data format for each type.%Raw data format for resource records."Raw data format for DNS questions..8Raw data format for the flags of DNS Query and Response.89Raw data format for the header of DNS Query and Response.<For backward compatibility.=+Raw data format for DNS Query and Response.D9An enumeration of all possible DNS errors that can occur.E\The sequence number of the answer doesn't match our query. This could indicate foul play.FThe request simply timed out.GWThe answer has the correct sequence number, but returned an unexpected RDATA format.H The domain for query is illegal.I2The name server was unable to interpret the query.JZThe name server was unable to process this query due to a problem with the name server.KMeaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.L=The name server does not support the requested kind of query.M)The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.N'The server detected a malformed OPT RR.RTypes for resource records.iType for domain.Making Question.x  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnov  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRUSTVWXYZ[\]^_`abcdefghijklmno    !"#$%&'()*+,-. /0123456789:;<=>?@ABCD EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnoNonep  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRUSTVWXYZ[\]^_`abcdefghijklmnoqi RSTUVWXYZ[\]^_`abcdefghjkOPQlmDEFGHIJKLMN=>?@ABC<89:;./01234567+,-'()* !"#$%&noNone9;)(#None0pReceiving DNS data from  and parse it.qParsing DNS data.rEParse many length-encoded DNS records, for example, from TCP traffic.pqrspqrqrppqrsNone!"uAComposing query. First argument is a number to identify response.wComposing DNS data.uvwuvwwuvuvwNonex Perform both y and z on the given ii. When comparing DNS names taken from user input, this is often necessary to avoid unexpected results.Examples:#let domain1 = BS.pack "ExAmPlE.COM"$let domain2 = BS.pack "example.com."domain1 == domain2False&normalize domain1 == normalize domain2TrueThe x function should be idempotent:2normalize (normalize domain1) == normalize domain1True(Ensure that we don't crash on the empty i:6import qualified Data.ByteString.Char8 as BS ( empty )normalize BS.empty"."y9Normalize the case of the given DNS name for comparisons.YAccording to RFC #1035, "For all parts of the DNS that are part of the official protocol, all comparisons between character strings (e.g., labels, domain names, etc.) are done in a case-insensitive manner." This function chooses to lowercase its argument, but that should be treated as an implementation detail if at all possible.Examples:#let domain1 = BS.pack "ExAmPlE.COM"#let domain2 = BS.pack "exAMPle.com"domain1 == domain2False.normalizeCase domain1 == normalizeCase domain2TrueThe y function should be idempotent:>normalizeCase (normalizeCase domain2) == normalizeCase domain2True(Ensure that we don't crash on the empty i:6import qualified Data.ByteString.Char8 as BS ( empty )normalizeCase BS.empty""zeNormalize the given name by appending a trailing dot (the DNS root) if one does not already exist.Warning: this does not produce an equivalent DNS name! However, users are often unaware of the effect that the absence of the root will have. In user interface design, it may therefore be wise to act as if the user supplied the trailing dot during comparisons.Per RFC #1034,"Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this property to distinguish between:za character string which represents a complete domain name (often called 'absolute'). For example, 'poneria.ISI.EDU.' a character string that represents the starting labels of a domain name which is incomplete, and should be completed by local software using knowledge of the local domain (often called 'relative'). For example, 'poneria' used in the ISI.EDU domain.FRelative names are either taken relative to a well known origin, or to a list of domains used as a search list. Relative names appear mostly at the user interface, where their interpretation varies from implementation to implementation, and in master files, where they are relative to a single origin domain name."Examples:#let domain1 = BS.pack "example.com"$let domain2 = BS.pack "example.com."domain1 == domain2False.normalizeRoot domain1 == normalizeRoot domain2TrueThe z function should be idempotent:>normalizeRoot (normalizeRoot domain1) == normalizeRoot domain1True(Ensure that we don't crash on the empty i:6import qualified Data.ByteString.Char8 as BS ( empty )normalizeRoot BS.empty"."xyzxyzxyzxyzNone{^Abstract data type of DNS Resolver When implementing a DNS cache, this MUST NOT be re-used.bAbstract data type of DNS Resolver seed. When implementing a DNS cache, this should be re-used.CType for resolver configuration. The easiest way to construct a  ResolvConf object is to modify the .Timeout in micro seconds..The number of retries including the first try.This field was obsoleted.Union type for  and  . Specify . to "resolv.conf" or numeric IP address in  form.Warning&: Only numeric IP addresses are valid  RCHostNames.*Example (using Google's public DNS cache): let cache = RCHostName "8.8.8.8"A path for "resolv.conf"A numeric IP address$A numeric IP address and port numberReturn a default : is  "/etc/resolv.conf". is 3,000,000 micro seconds. is 3. is 512. (obsoleted)?Example (use Google's public DNS cache instead of resolv.conf): let cache = RCHostName "8.8.8.8"1let rc = defaultResolvConf { resolvInfo = cache }Make a  from a . Examples:&rs <- makeResolvSeed defaultResolvConfGiving a thread-safe {p to the function of the second argument. A socket for UDP is opened inside and is surely closed. Multiple Zs can be used concurrently. Multiple lookups must be done sequentially with a given {. If multiple {/s are necessary for concurrent purpose, use .Giving thread-safe {rs to the function of the second argument. Sockets for UDP are opened inside and are surely closed. For each {1, multiple lookups must be done sequentially. {s can be used concurrently.eLooking up resource records of a domain. The first parameter is one of the field accessors of the = type -- this allows you to choose which section (answer, authority, or additional) you would like to inspect for the result.#Extract necessary information from =For backward compatibility.iLook up resource records for a domain, collecting the results from the ANSWER section of the response.We repeat an example from Network.DNS.Lookup:;let hostname = Data.ByteString.Char8.pack "www.example.com"&rs <- makeResolvSeed defaultResolvConf9withResolver rs $ \resolver -> lookup resolver hostname ARight [93.184.216.34]lLook up resource records for a domain, collecting the results from the AUTHORITY section of the response.eLook up a name and return the entire DNS Response. Sample output is included below, however it is notC tested -- the sequence number is unpredictable (it has to be!).The example code:  let hostname = Data.ByteString.Char8.pack "www.example.com" rs <- makeResolvSeed defaultResolvConf withResolver rs $ resolver -> lookupRaw resolver hostname A $And the (formatted) expected output: H Right (DNSMessage { header = DNSHeader { identifier = 1, flags = DNSFlags { qOrR = QR_Response, opcode = OP_STD, authAnswer = False, trunCation = False, recDesired = True, recAvailable = True, rcode = NoErr, authenData = False }, }, question = [Question { qname = "www.example.com.", qtype = A}], answer = [ResourceRecord {rrname = "www.example.com.", rrtype = A, rrttl = 800, rdlen = 4, rdata = 93.184.216.119}], authority = [], additional = []}) ){|}~{|}~{|}~{|}~None /Look up all 'A' records for the given hostname.A straightforward example:7let hostname = Data.ByteString.Char8.pack "www.mew.org"&rs <- makeResolvSeed defaultResolvConf8withResolver rs $ \resolver -> lookupA resolver hostnameRight [210.130.207.72]hThis function will also follow a CNAME and resolve its target if one exists for the queries hostname:8let hostname = Data.ByteString.Char8.pack "www.kame.net"&rs <- makeResolvSeed defaultResolvConf8withResolver rs $ \resolver -> lookupA resolver hostnameRight [203.178.141.194]9Look up all (IPv6) 'AAAA' records for the given hostname. Examples::let hostname = Data.ByteString.Char8.pack "www.wide.ad.jp"&rs <- makeResolvSeed defaultResolvConf;withResolver rs $ \resolver -> lookupAAAA resolver hostname,Right [2001:200:dff:fff1:216:3eff:fe4b:651c]Look up all 'MX' records for the given hostname. Two parts constitute an MX record: a hostname , and an integer priority. We therefore return each record as a (i, Int).In this first example, we look up the MX for the domain "example.com". It has no MX (to prevent a deluge of spam from examples posted on the internet). But remember, "no results" is still a successful result.7let hostname = Data.ByteString.Char8.pack "example.com"&rs <- makeResolvSeed defaultResolvConf9withResolver rs $ \resolver -> lookupMX resolver hostnameRight []3The domain "mew.org" does however have a single MX:3let hostname = Data.ByteString.Char8.pack "mew.org"&rs <- makeResolvSeed defaultResolvConf9withResolver rs $ \resolver -> lookupMX resolver hostnameRight [("mail.mew.org.",10)]ZAlso note that all hostnames are returned with a trailing dot to indicate the DNS root.uLook up all 'MX' records for the given hostname, and then resolve their hostnames to IPv4 addresses by calling ". The priorities are not retained. Examples:import Data.List (sort)6let hostname = Data.ByteString.Char8.pack "wide.ad.jp"&rs <- makeResolvSeed defaultResolvConfDips <- withResolver rs $ \resolver -> lookupAviaMX resolver hostname fmap sort ips$Right [133.138.10.34,203.178.136.49]hSince there is more than one result, it is necessary to sort the list in order to check for equality.uLook up all 'MX' records for the given hostname, and then resolve their hostnames to IPv6 addresses by calling ". The priorities are not retained..This function performs the real work for both  and >. The only difference between those two is which function,  or S, is used to perform the lookup. We take either of those as our first parameter.Look up all 'NS' records for the given hostname. The results are taken from the ANSWER section of the response (as opposed to AUTHORITY). 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. Examples:import Data.List (sort)3let hostname = Data.ByteString.Char8.pack "mew.org"&rs <- makeResolvSeed defaultResolvConf?ns <- withResolver rs $ \resolver -> lookupNS resolver hostname fmap sort ns%Right ["ns1.mew.org.","ns2.mew.org."]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 % 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)7let hostname = Data.ByteString.Char8.pack "example.com"6let ri = RCHostName "192.5.6.30" -- a.gtld-servers.net.let rc = defaultResolvConf { resolvInfo = ri }rs <- makeResolvSeed rcCns <- withResolver rs $ \resolver -> lookupNSAuth resolver hostname fmap sort ns3Right ["a.iana-servers.net.","b.iana-servers.net."]OLook up all 'TXT' records for the given hostname. The results are free-form s.)Two common uses for 'TXT' records are  4http://en.wikipedia.org/wiki/Sender_Policy_Framework and  7http://en.wikipedia.org/wiki/DomainKeys_Identified_Mail9. As an example, we find the SPF record for "mew.org":3let hostname = Data.ByteString.Char8.pack "mew.org"&rs <- makeResolvSeed defaultResolvConf:withResolver rs $ \resolver -> lookupTXT resolver hostnameRight ["v=spf1 +mx -all"]Look up all 'PTR' records for the given hostname. To perform a reverse lookup on an IP address, you must first reverse its octets and then append the suffix ".in-addr.arpa."gWe look up the PTR associated with the IP address 210.130.137.80, i.e., 80.137.130.210.in-addr.arpa:Flet hostname = Data.ByteString.Char8.pack "164.2.232.202.in-addr.arpa"&rs <- makeResolvSeed defaultResolvConf:withResolver rs $ \resolver -> lookupPTR resolver hostnameRight ["www.iij.ad.jp."]The 1 function is more suited to this particular task.Convenient wrapper around 7 to perform a reverse lookup on a single IP address.We repeat the example from 0, except now we pass the IP address directly:9let hostname = Data.ByteString.Char8.pack "202.232.2.164"&rs <- makeResolvSeed defaultResolvConf;withResolver rs $ \resolver -> lookupRDNS resolver hostnameRight ["www.iij.ad.jp."]XLook up all 'SRV' records for the given hostname. A SRV record comprises four fields,"Priority (lower is more-preferred)kWeight (relative frequency with which to use this record amongst all results with the same priority)/Port (the port on which the service is offered)5Target (the hostname on which the service is offered)mThe first three are integral, and the target is another DNS hostname. We therefore return a four-tuple  (Int,Int,Int,i). Examples:?let hostname = Data.ByteString.Char8.pack "_sip._tcp.cisco.com"&rs <- makeResolvSeed defaultResolvConf:withResolver rs $ \resolver -> lookupSRV resolver hostname%Right [(1,0,5060,"vcsgw.cisco.com.")]   None  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRUSTVWXYZ[\]^_`abcdefghijklmnopqruvwxyz{|}~     !"#$$%&'()*+,-./01234566789:;<=>??@ABCCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   dns-2.0.8-LnbS5OWrixG5iLbXxM4hkoNetwork.DNS.TypesNetwork.DNS.DecodeNetwork.DNS.EncodeNetwork.DNS.UtilsNetwork.DNS.ResolverNetwork.DNS.LookupNetwork.DNS.InternalNetwork.DNS.StateBinary Network.DNSODataOD_ClientSubnet OD_UnknownRDataRD_NSRD_CNAMERD_DNAMERD_MXRD_PTRRD_SOARD_ARD_AAAARD_TXTRD_SRVRD_OPTRD_OTHRD_TLSAResourceRecord OptRecordrrnamerrtyperrttlrdata orudpsize ordnssecok orversionQuestionqnameqtypeRCODENoErr FormatErrServFailNameErrNotImplRefusedBadOptOPCODEOP_STDOP_INVOP_SSRQorRQR_Query QR_ResponseDNSFlagsqOrRopcode authAnswer trunCation recDesired recAvailablercode authenData DNSHeader identifierflags DNSFormat DNSMessageheaderquestionanswer authority additionalDNSErrorSequenceNumberMismatchTimeoutExpiredUnexpectedRDATA IllegalDomain FormatError ServerFailure NameErrorNotImplementedOperationRefused BadOptRecordOPTTYPE ClientSubnetOUNKNOWNTYPEAAAAANSTXTMXCNAMESOAPTRSRVDNAMEOPTDSRRSIGNSECDNSKEYNSEC3 NSEC3PARAMTLSACDSCDNSKEYCSYNCUNKNOWNDomain intToType typeToInt intToOptType optTypeToInt responseA responseAAAAreceivedecode decodeMany$fExceptionRDATAParseError$fShowRDATAParseError composeQuerycomposeQueryADencode normalize normalizeCase normalizeRootResolvergenIddnsSock dnsTimeoutdnsRetry dnsBufsize ResolvSeed ResolvConf resolvInfo resolvTimeout resolvRetry resolvBufsizeFileOrNumericHost RCFilePath RCHostName RCHostPortdefaultResolvConfmakeResolvSeed withResolver withResolversfromDNSMessage fromDNSFormatlookup lookupAuth lookupRaw lookupRawADlookupA lookupAAAAlookupMX lookupAviaMXlookupAAAAviaMXlookupNS lookupNSAuth lookupTXT lookupPTR lookupRDNS lookupSRV makeQuestionrrDBorDBrookup defaultQuerydefaultResponse $fShowRData$fExceptionDNSErrorPStatepsDomain psPositionSGetWStatewsDomain wsPositionSPut initialWStateput8put16put32putInt8putInt16putInt32 putByteString addPositionW fixedSized writeSizedwsPopwsPush getPosition addPositionpushpopget8get16get32getInt8getInt16getInt32 getNBytesgetNByteString initialStatesinkSGetrunSGetrunSGetWithLeftoversrunSPut$fMonoidStateT&network-2.6.3.1-G4Up1CPKbp7DeFsnywOnGGNetwork.Socket.TypesSocketRDATAParseErrorreceiveDNSFormatdecodeResponse decodeFlags decodeHeader decodeQueries decodeType decodeOptType decodeQuery decodeRRsdecodeRR decodeRData decodeOData decodeDomain ignoreClassencodeDNSMessage encodeHeader encodeFlagsencodeQuestionputRDataencodeRR encodeRDATA encodeODataputByteStringWithLength rootDomain encodeDomain encodePointerencodePartialDomainbaseGHC.IOFilePathNetwork.SocketHostNameGHC.BaseString lookupSectionaddrInfo rsTimeoutrsRetry rsBufsize makeAddrInfo openSocket connectSocket makeResolver getRandomlookupRawInternal isIllegal lookupNSImplbytestring-0.10.8.1Data.ByteString.Internal ByteString lookupXviaMX