X-Git-Url: http://gitweb.michael.orlitzky.com/?p=haeredes.git;a=blobdiff_plain;f=src%2FMain.hs;h=6b276b7980b9b5687493f6b72ab46590d5fb9b9d;hp=5c6f401f7a5e839b6f5545bd4e4bba91cd6b3195;hb=95bd7958d5a3483ba2cbe232765138a7785b2429;hpb=7cc26ab4bfa90c4abe0c741d5a3eaf575544466a diff --git a/src/Main.hs b/src/Main.hs index 5c6f401..6b276b7 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -32,7 +32,12 @@ import DNS ( resolve_address ) import ExitCodes (exit_bad_server) -report :: (Domain, Maybe [Domain]) -> IO () + +-- | Report results for this LookupResult. If there's a Nothing in the +-- second component, there were no query results, so we report that +-- the domain was not delegated. If there were some results and +-- there are leftovers (after "cleaning"), we report those as well. +report :: LookupResult -> IO () report (d, Nothing) = putStrLn $ "Domain " ++ (show d) ++ " not delegated." report (d, Just leftovers) = @@ -42,6 +47,11 @@ report (d, Just leftovers) = " delegates somewhere else: " ++ (join " " (map show leftovers)) + +-- | "Clean" a lookup result by subtracting out the list of delegates. +-- There shouldn't be anything left over. If there were no lookup +-- results, we leave the Nothing in place so that 'report' can +-- pattern match on it. clean :: [Domain] -- ^ List of delegates, @ds@ -> LookupResult -> LookupResult @@ -88,8 +98,8 @@ main = do rs <- makeResolvSeed rc let lookup_function = case cfg of - (NS _ _ _) -> lookupNS' - (MX _ _ _) -> lookupMX' + NS{} -> lookupNS' + MX{} -> lookupMX' _ <- withResolver rs $ \resolver -> do -- Bad stuff happens if we try to run these lookups in parallel