Hoogle Search

Within LTS Haskell 24.36 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. lookupMX :: Resolver -> Domain -> IO (Either DNSError [(Domain, Int)])

    dns Network.DNS.Lookup

    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 (Domain, Int). In this first example, we look up the MX for the domain "example.com". It has an RFC7505 NULL MX (to prevent a deluge of spam from examples posted on the internet).

    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupMX resolver "example.com"
    Right [(".",0)]
    
    The domain "mew.org" does however have a single MX:
    >>> rs2 <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs2 $ \resolver -> lookupMX resolver "mew.org"
    Right [("mail.mew.org.",10)]
    
    Also note that all hostnames are returned with a trailing dot to indicate the DNS root. However the MX host itself has no need for an MX record, so its MX RRset is empty. But, "no results" is still a successful result.
    >>> rs3 <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs3 $ \resolver -> lookupMX resolver "mail.mew.org"
    Right []
    

  2. lookupNS :: Resolver -> Domain -> IO (Either DNSError [Domain])

    dns Network.DNS.Lookup

    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)
    
    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> ns <- withResolver rs $ \resolver -> lookupNS resolver "mew.org"
    
    >>> fmap sort ns
    Right ["ns1.mew.org.","ns2.mew.org."]
    

  3. lookupNSAuth :: Resolver -> Domain -> IO (Either DNSError [Domain])

    dns Network.DNS.Lookup

    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."]
    

  4. lookupPTR :: Resolver -> Domain -> IO (Either DNSError [Domain])

    dns Network.DNS.Lookup

    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." We look up the PTR associated with the IP address 210.130.137.80, i.e., 80.137.130.210.in-addr.arpa:

    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupPTR resolver "180.2.232.202.in-addr.arpa"
    Right ["www.iij.ad.jp."]
    
    The lookupRDNS function is more suited to this particular task.

  5. lookupRDNS :: Resolver -> Domain -> IO (Either DNSError [Domain])

    dns Network.DNS.Lookup

    Convenient wrapper around lookupPTR to perform a reverse lookup on a single IP address. We repeat the example from lookupPTR, except now we pass the IP address directly:

    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupRDNS resolver "202.232.2.180"
    Right ["www.iij.ad.jp."]
    

  6. lookupSOA :: Resolver -> Domain -> IO (Either DNSError [(Domain, Mailbox, Word32, Word32, Word32, Word32, Word32)])

    dns Network.DNS.Lookup

    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.","[email protected].")]
    

  7. lookupSRV :: Resolver -> Domain -> IO (Either DNSError [(Word16, Word16, Word16, Domain)])

    dns Network.DNS.Lookup

    Look up all 'SRV' records for the given hostname. SRV records consist (see https://tools.ietf.org/html/rfc2782) of the following four fields:

    • Priority (lower is more-preferred)
    • Weight (relative frequency with which to use this record amongst all results with the same priority)
    • Port (the port on which the service is offered)
    • Target (the hostname on which the service is offered)
    The first three are integral, and the target is another DNS hostname. We therefore return a four-tuple (Int,Int,Int,Domain). Examples:
    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupSRV resolver "_xmpp-server._tcp.jabber.ietf.org"
    Right [(5,0,5269,"_dc-srv.6661af51975d._xmpp-server._tcp.jabber.ietf.org.")]
    

  8. lookupTXT :: Resolver -> Domain -> IO (Either DNSError [ByteString])

    dns Network.DNS.Lookup

    Look up all 'TXT' records for the given hostname. The results are free-form ByteStrings. Two common uses for 'TXT' records are http://en.wikipedia.org/wiki/Sender_Policy_Framework and http://en.wikipedia.org/wiki/DomainKeys_Identified_Mail. As an example, we find the SPF record for "mew.org":

    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupTXT resolver "mew.org"
    Right ["v=spf1 +mx -all"]
    

  9. lookupAuth :: Resolver -> Domain -> TYPE -> IO (Either DNSError [RData])

    dns Network.DNS.LookupRaw

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

  10. lookupRaw :: Resolver -> Domain -> TYPE -> IO (Either DNSError DNSMessage)

    dns Network.DNS.LookupRaw

    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 EDNS if specifiecd). If it appears that the target DNS server does not support EDNS, it falls back to traditional queries.
    • If the response is truncated, a new TCP socket bound to a new local port is created. Then exactly one TCP query is retried.
    If multiple DNS servers 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 = []})
    
    
    AXFR requests cannot be performed with this interface.
    >>> rs <- makeResolvSeed defaultResolvConf
    
    >>> withResolver rs $ \resolver -> lookupRaw resolver "mew.org" AXFR
    Left InvalidAXFRLookup
    

Page 106 of many | Previous | Next