X-Git-Url: http://gitweb.michael.orlitzky.com/?p=hath.git;a=blobdiff_plain;f=src%2FDNS.hs;h=a535de59adeb17a75b3c52333504bc65303e4bee;hp=041eeeb52e2404b1d6951f3942cee600b8b28cc4;hb=a2afcdfec4ded920e133f28e069275caadc890c0;hpb=75f50904fd550972ad47c47c51932b8266eebe51 diff --git a/src/DNS.hs b/src/DNS.hs index 041eeeb..a535de5 100644 --- a/src/DNS.hs +++ b/src/DNS.hs @@ -6,36 +6,20 @@ module DNS ( where import Control.Concurrent.ParallelIO.Global ( parallel ) -import qualified Data.ByteString.Char8 as BS ( - append, - intercalate, - pack, - split ) import Network.DNS ( Domain, DNSError, ResolvConf(..), defaultResolvConf, - lookupPTR, + lookupRDNS, makeResolvSeed, withResolver ) --- The return type of lookupPTR. +-- The return type of lookupRDNS. type PTRResult = Either DNSError [Domain] --- | Convert the given IP address (as a ByteString) to the format --- required for a PTR lookup. For example, "192.168.0.0" should be --- converted to "0.0.168.192.in-addr.arpa". -ip_to_in_addr_arpa :: Domain -> Domain -ip_to_in_addr_arpa ip = - rev_ip `BS.append` suffix - where - dot = BS.pack "." - suffix = BS.pack ".in-addr.arpa" - rev_ip = BS.intercalate dot (reverse (BS.split '.' ip)) - -- | Take the default ResolvConf and increase the timeout to 15 -- seconds. our_resolv_conf :: ResolvConf @@ -49,9 +33,6 @@ lookup_ptrs :: [Domain] -> IO [PTRResult] lookup_ptrs ips = do rs <- makeResolvSeed our_resolv_conf let lookup' addr = withResolver rs $ \resolver -> - lookupPTR resolver addr - - parallel $ map lookup' in_addrs + lookupRDNS resolver addr - where - in_addrs = map ip_to_in_addr_arpa ips + parallel $ map lookup' ips