Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
-- stack ghci --package dns --package bytestring
-- import Network.DNS.Resolver
-- import Network.DNS.Lookup
-- import qualified Data.ByteString.Char8 as BSC
-- reads newline separated domain names and dumps their A records to an output file.
readFile "/tmp/domains.txt"
>>= return . map BSC.pack . lines
>>= \domains -> mapM (\d -> withResolver seed (\s -> lookupA s d >>= return . (,) d )) domains
>>= \ts -> writeFile "/tmp/resolv.txt" $ unlines . map show $ ts
-- beware of very large files!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment