Copyright | (c) 2008 Peter Simons |
---|---|
License | LGPL |
Maintainer | simons@cryp.to |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
This module implements a Haskell DNS Resolver on top of the
ADNS library. GHC users should compile their code using the
-threaded
runtime system.
- type Resolver = String -> RRType -> [QueryFlag] -> IO (MVar Answer)
- initResolver :: [InitFlag] -> (Resolver -> IO a) -> IO a
- toPTR :: HostAddress -> String
- resolveA :: Resolver -> HostName -> IO (Either Status [HostAddress])
- resolvePTR :: Resolver -> HostAddress -> IO (Either Status [HostName])
- resolveMX :: Resolver -> HostName -> IO (Either Status [(HostName, HostAddress)])
- resolveSRV :: Resolver -> HostName -> IO (Either Status [(HostName, PortID)])
- query :: (Resolver -> a -> IO (Either Status [b])) -> Resolver -> a -> IO (Maybe [b])
- dummyDNS :: Resolver
Documentation
toPTR :: HostAddress -> String Source #
Print an IP host address as a string suitable for PTR
lookups.
resolveA :: Resolver -> HostName -> IO (Either Status [HostAddress]) Source #
Resolve a hostname's A
records.
resolvePTR :: Resolver -> HostAddress -> IO (Either Status [HostName]) Source #
Get the PTR
records assigned to a host address. Note
that although the API allows for a record to have more
than one PTR
entry, this will actually not happen
because the GNU adns library can't handle this case and
will return sINCONSISTENT
.
resolveSRV :: Resolver -> HostName -> IO (Either Status [(HostName, PortID)]) Source #
Resolve a hostname's SRV
records.
query :: (Resolver -> a -> IO (Either Status [b])) -> Resolver -> a -> IO (Maybe [b]) Source #
Convenience wrapper that will modify any of the
revolveXXX
functions above to return Maybe
rather
than Either
. The idea is that Nothing
signifies any
sort of failure: Just []
signifies sNXDOMAIN
or
sNODATA
, and everything else signifies sOK
.
So if you aren't interested in getting accurate Status
codes in case of failures. Wrap your DNS queries as
follows:
queryA :: Resolver -> HostName -> IO (Maybe [HostAddress]) queryA = query resolveA