Require dns >= 1.4 and use its 'normalize' function.
[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 -- Slow since we create the resolver every time.
12 lookup_mxs :: Domain -> IO [Domain]
13 lookup_mxs domain = do
14 default_rs <- makeResolvSeed defaultResolvConf
15 withResolver default_rs $ \resolver -> do
16 mxs <- lookupMX resolver domain
17 return $ case mxs of
18 Left _ -> []
19 Right pairs -> map fst pairs