diff options
author | Kazu Yamamoto <kazu@iij.ad.jp> | 2011-10-24 16:14:27 +0900 |
---|---|---|
committer | Kazu Yamamoto <kazu@iij.ad.jp> | 2011-10-24 16:14:27 +0900 |
commit | 4fa2676715d20ad9b7b01d504188a538cd20194d (patch) | |
tree | f0e16437255a996f456b9ccebd6a2bb24783c0df | |
parent | d16870464640fcd94d318a919dbf10eec0f96ee3 (diff) |
ordering.
-rw-r--r-- | Network/DNS/Decode.hs | 6 | ||||
-rw-r--r-- | Network/DNS/Encode.hs | 21 | ||||
-rw-r--r-- | Network/DNS/Resolver.hs | 14 |
3 files changed, 24 insertions, 17 deletions
diff --git a/Network/DNS/Decode.hs b/Network/DNS/Decode.hs index c84a06d..bb376da 100644 --- a/Network/DNS/Decode.hs +++ b/Network/DNS/Decode.hs @@ -1,8 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} module Network.DNS.Decode ( - receive - , decode + decode + , receive ) where import Control.Applicative @@ -29,6 +29,8 @@ receive sock bufsize = receiveDNSFormat responseEnum where responseEnum = enumSocket bufsize sock +---------------------------------------------------------------- + {-| Parsing DNS data. -} decode :: BL.ByteString -> Either String DNSFormat diff --git a/Network/DNS/Encode.hs b/Network/DNS/Encode.hs index 6116a04..c3457f2 100644 --- a/Network/DNS/Encode.hs +++ b/Network/DNS/Encode.hs @@ -1,5 +1,8 @@ {-# LANGUAGE RecordWildCards #-} -module Network.DNS.Encode (encode) where +module Network.DNS.Encode ( + encode + , composeQuery + ) where import qualified Data.ByteString.Lazy.Char8 as BL (ByteString) import qualified Data.ByteString.Char8 as BS (length, null, break, drop) @@ -16,6 +19,22 @@ import Data.IP ---------------------------------------------------------------- +{-| Composing query. First argument is a number to identify response. +-} +composeQuery :: Int -> [Question] -> BL.ByteString +composeQuery idt qs = encode qry + where + hdr = header defaultQuery + qry = defaultQuery { + header = hdr { + identifier = idt + , qdCount = length qs + } + , question = qs + } + +---------------------------------------------------------------- + {-| Composing DNS data. -} encode :: DNSFormat -> BL.ByteString diff --git a/Network/DNS/Resolver.hs b/Network/DNS/Resolver.hs index 44aee7d..e7f043b 100644 --- a/Network/DNS/Resolver.hs +++ b/Network/DNS/Resolver.hs @@ -182,17 +182,3 @@ lookupRaw rlv dom typ = do if identifier hdr == seqno && anCount hdr /= 0 then Just res else Nothing - ----------------------------------------------------------------- - -composeQuery :: Int -> [Question] -> BL.ByteString -composeQuery idt qs = encode qry - where - hdr = header defaultQuery - qry = defaultQuery { - header = hdr { - identifier = idt - , qdCount = length qs - } - , question = qs - } |