From 4fa2676715d20ad9b7b01d504188a538cd20194d Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Mon, 24 Oct 2011 16:14:27 +0900 Subject: ordering. --- Network/DNS/Decode.hs | 6 ++++-- Network/DNS/Encode.hs | 21 ++++++++++++++++++++- 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 - } -- cgit v1.2.3