words )
import Data.List ( (\\), intersperse )
import Network.DNS (
+ DNSError(NameError),
Domain,
FileOrNumericHost(RCHostName),
ResolvConf(resolvInfo, resolvTimeout),
-> LookupResult
-> IO ()
--- If the lookup resulted in a DNS error, we just ignore the whole
--- thing.
-report _ _ (_, Left _) = return ()
-
-- If the lookup succeeded but there were no results, report that the
--- domain is not delegated.
-report _ _ (d, Right []) =
+-- domain is not delegated. Note that the behavior of the DNS library
+-- changed with regard to this at some point: we used to get back
+-- a "success," but with an empty list of results. Now a NameError
+-- (which is not actually an error!) is returned.
+report _ _ (d, Left NameError) =
putStrLn $ "Domain " ++ (show d) ++ " not delegated."
+-- If the lookup resulted in some other DNS error, we just ignore the
+-- whole thing.
+report _ _ (_, Left _) = return ()
+
-- Otherwise, subtract our delegates from the list of results and
-- report the leftovers.
report delgts normalize_function (d, Right raw_hosts) = do