dns-0.3.1: DNS libary in Haskell




DNS Resolver and lookup functions.

Sample code:

    import qualified Network.DNS as DNS (lookup)
    import Network.DNS hiding (lookup)
    main :: IO ()
    main = do
        rs <- makeResolvSeed defaultResolvConf
        withResolver rs $ \resolver -> do
            DNS.lookup resolver "www.example.com" A >>= print



Configuration for resolver

data FileOrNumericHost Source

Union type for FilePath and HostName. Specify FilePath to "resolv.conf" or numeric IP address in String form.

data ResolvConf Source

Type for resolver configuration

defaultResolvConf :: ResolvConfSource

Default ResolvConf. resolvInfo is RCFilePath "/etc/resolv.conf". resolvTimeout is 3,000,000 micro seconds. resolvBufsize is 512.

Intermediate data type for resolver

data ResolvSeed Source

Abstract data type of DNS Resolver seed

makeResolvSeed :: ResolvConf -> IO ResolvSeedSource

Making ResolvSeed from an IP address of a DNS cache server.

Type and function for resolver

data Resolver Source

Abstract data type of DNS Resolver



withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO aSource

Giving a thread-safe Resolver to the function of the second argument. withResolver should be passed to forkIO.

Looking up functions

lookup :: Resolver -> Domain -> TYPE -> IO (Maybe [RDATA])Source

Looking up resource records of a domain.

lookupRaw :: Resolver -> Domain -> TYPE -> IO (Maybe DNSFormat)Source

Looking up a domain and returning an entire DNS Response.