network-dns-0.1: A pure Haskell, asyncronous DNS client libraryContentsIndex
Network.DNS.Client
Description

A DNS resolver. This code acts like the resolver library from libc, except that it can work asynchronously, and can return much more information.

At the moment, the interface is very much undecided but currently looks like this:

 import qualified Network.DNS.Client as DNS

 DNS.resolve DNS.A "somedomain.com"
 Right [(2008-02-01 00:27:14.861098 UTC, DNS.RRA [2466498203])]

The first element of the tuple is the time when the information expires. The second depends on the record type requested (A, in this case) and A records contain IP address, so that's a HostAddress in there.

This module parses etcresolv.conf for it's configuration. It needs a recursive server to do the hard work. If you're lacking a recursive server, you can setup dnscache (from djbdns) locally and point at that.

Synopsis
module Network.DNS.Types
resolve :: DNSType -> String -> IO (Either DNSError [(UTCTime, RR)])
resolveAsync :: DNSType -> String -> (Either DNSError [(UTCTime, RR)] -> IO ()) -> IO ()
data DNSError
= Timeout
| AnswerNotIncluded
| DNSError ResponseCode
Documentation
module Network.DNS.Types
resolve
:: DNSTypethe type of DNS information requested
-> Stringthe domain to query
-> IO (Either DNSError [(UTCTime, RR)])The RR values here will always be of the correct type for the requested DNSType
Lookup some information from DNS
resolveAsync :: DNSType -> String -> (Either DNSError [(UTCTime, RR)] -> IO ()) -> IO ()
This is the same as resolve, below, put you get the answer asynchronously. Blocking the thread which makes the callback in this case is bad - it'll block the DNS network reading thread.
data DNSError
This is the type of errors from the library. Either it's one of the first two errors (which are generated from within this code), or it's an error directly from the DNS server.
Constructors
Timeoutthe DNS server didn't answer
AnswerNotIncluded

this is returned when the DNS server returned a valid answer, but the answer didn't include the information we were looking for. Firstly, this isn't a recursive resolver, so if you point it at a non-recursive server you'll get this for nearly every query as the server will just be telling us the location of the roots.

This can also occur when you ask for a resource which doesn't exist - like a AAAA record from www.google.com

DNSError ResponseCodeerrors from the DNS server
show/hide Instances
Produced by Haddock version 0.8