dns-3.0.4: DNS library in Haskell
Safe Haskell None
Language Haskell2010

Network.DNS.LookupRaw

Synopsis

Looking up functions

lookup :: Resolver -> Domain -> TYPE -> IO ( Either DNSError [ RData ]) Source #

Look up resource records of a specified type for a domain, collecting the results from the ANSWER section of the response. See manual the manual of lookupRaw to understand the concrete behavior. Cache is used if resolvCache is Just .

Example:

>>> rs <- makeResolvSeed defaultResolvConf
>>> withResolver rs $ \resolver -> lookup resolver "www.example.com" A
Right [93.184.216.34]

lookupAuth :: Resolver -> Domain -> TYPE -> IO ( Either DNSError [ RData ]) Source #

Look up resource records of a specified type for a domain, collecting the results from the AUTHORITY section of the response. See manual the manual of lookupRaw to understand the concrete behavior. Cache is used even if resolvCache is Just .

Raw looking up function

lookupRaw :: Resolver -> Domain -> TYPE -> IO ( Either DNSError DNSMessage ) Source #

Look up a name and return the entire DNS Response

For a given DNS server, the queries are done:

  • A new UDP socket bound to a new local port is created and a new identifier is created atomically from the cryptographically secure pseudo random number generator for the target DNS server. Then UDP queries are tried with the limitation of resolvRetry (use EDNS0 if specifiecd). If it appear that the target DNS server does not support EDNS0, it falls back to traditional queries.
  • If the response is truncated, a new TCP socket bound to a new locla port is created. Then exactly one TCP query is retried.

If multiple DNS server are specified ResolvConf ('RCHostNames ') or found ( RCFilePath ), either sequential lookup or concurrent lookup is carried out:

  • In sequential lookup ( resolvConcurrent is False), the query procedure above is processed in the order of the DNS servers sequentially until a successful response is received.
  • In concurrent lookup ( resolvConcurrent is True), the query procedure above is processed for each DNS server concurrently. The first received response is accepted even if it is an error.

Cache is not used even if resolvCache is Just .

The example code:

  rs <- makeResolvSeed defaultResolvConf
  withResolver rs $ \resolver -> lookupRaw resolver "www.example.com" A
  

And the (formatted) expected output:

  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 = []})
 

lookupRawAD :: Resolver -> Domain -> TYPE -> IO ( Either DNSError DNSMessage ) Source #

Same as lookupRaw but the query sets the AD bit, which solicits the the authentication status in the server reply. In most applications (other than diagnostic tools) that want authenticated data It is unwise to trust the AD bit in the responses of non-local servers, this interface should in most cases only be used with a loopback resolver.

fromDNSFormat :: DNSMessage -> ( DNSMessage -> a) -> Either DNSError a Source #

Deprecated: Use fromDNSMessage instead

For backward compatibility.