Skip to content

Instantly share code, notes, and snippets.

@asheshambasta
Created July 23, 2018 11:54
Show Gist options
  • Save asheshambasta/d3cf739ea683b0a49ed3b721cb3502f2 to your computer and use it in GitHub Desktop.
Save asheshambasta/d3cf739ea683b0a49ed3b721cb3502f2 to your computer and use it in GitHub Desktop.
-- 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