Add a doctest test suite.
[list-remote-forwards.git] / src / DNS.hs
1 module DNS ( lookup_mxs )
2 where
3
4 import Network.DNS (
5 Domain,
6 defaultResolvConf,
7 lookupMX,
8 makeResolvSeed,
9 withResolver )
10
11
12 -- | Retrieve all MX records for the given domain. This is somewhat
13 -- inefficient, since we create the resolver every time.
14 --
15 lookup_mxs :: Domain -> IO [Domain]
16 lookup_mxs domain = do
17 default_rs <- makeResolvSeed defaultResolvConf
18 withResolver default_rs $ \resolver -> do
19 mxs <- lookupMX resolver domain
20 return $ case mxs of
21 Left _ -> []
22 Right pairs -> map fst pairs