From: Michael Orlitzky Date: Sat, 2 Mar 2019 02:27:19 +0000 (-0500) Subject: src/Main.hs: fix handling of "domain not found" errors. X-Git-Tag: 0.5.1~8 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=haeredes.git;a=commitdiff_plain;h=3f25fc286646f24a1f40e0acda74a6907d2f08f9 src/Main.hs: fix handling of "domain not found" errors. The "not delegated" example in the man page is now failing, because we're getting back a NameError (failure result) instead of an empty success result. I'm not sure when this changed -- and my fix is probably backwards-incompatible -- but I've updated haeredes to look for the NameError rather than an empty result. The documented example works again, but I've only tested with v3.0.2 of the "dns" library. --- diff --git a/src/Main.hs b/src/Main.hs index 89d2cd5..c93697a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -11,6 +11,7 @@ import qualified Data.ByteString.Char8 as BS ( words ) import Data.List ( (\\), intersperse ) import Network.DNS ( + DNSError(NameError), Domain, FileOrNumericHost(RCHostName), ResolvConf(resolvInfo, resolvTimeout), @@ -52,15 +53,18 @@ report :: [Domain] -- ^ The list of @delgts@ -> 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