X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FDNS%2FMessage.hs;h=9f2b144968c7f394e84068dae3a8cccd84b9b259;hb=d24a461f09bd10e3fe148e3b6b86c8e861b09a43;hp=17c037f7dba99a18a3c4457f670a5aaa017b5a54;hpb=caf521ccd3edd8a9f042d1aa8a097b98cf40c1da;p=haskell-dns.git diff --git a/Network/DNS/Message.hs b/Network/DNS/Message.hs index 17c037f..9f2b144 100644 --- a/Network/DNS/Message.hs +++ b/Network/DNS/Message.hs @@ -19,8 +19,8 @@ module Network.DNS.Message , SOAFields(..) , WKSFields(..) - , SomeQ - , SomeRR + , SomeQ(..) + , SomeRR(..) , A(..) , NS(..) @@ -50,6 +50,9 @@ module Network.DNS.Message , HS(..) , mkDomainName + , mkDN + , isZoneOf + , wrapQuestion , wrapRecord ) @@ -70,6 +73,7 @@ import qualified Data.IntMap as IM import Data.IntMap (IntMap) import qualified Data.IntSet as IS import Data.IntSet (IntSet) +import Data.List import qualified Data.Map as M import Data.Map (Map) import Data.Word @@ -224,6 +228,9 @@ unconsLabel :: DomainName -> (DomainLabel, DomainName) unconsLabel (DN (x:xs)) = (x, DN xs) unconsLabel x = error ("Illegal use of unconsLabel: " ++ show x) +isZoneOf :: DomainName -> DomainName -> Bool +isZoneOf (DN a) (DN b) = a `isSuffixOf` b + mkDomainName :: String -> DomainName mkDomainName = DN . mkLabels [] . notEmpty where @@ -237,6 +244,9 @@ mkDomainName = DN . mkLabels [] . notEmpty -> mkLabels (C8.pack l : soFar) rest _ -> error ("Illegal domain name: " ++ xs) +mkDN :: String -> DomainName +mkDN = mkDomainName + class (Show rc, Eq rc, Typeable rc) => RecordClass rc where rcToInt :: rc -> Int @@ -904,4 +914,4 @@ wrapQuestion :: (QueryType qt, QueryClass qc) => Question qt qc -> SomeQ wrapQuestion = SomeQ wrapRecord :: (RecordType rt dt, RecordClass rc) => ResourceRecord rt rc dt -> SomeRR -wrapRecord = SomeRR \ No newline at end of file +wrapRecord = SomeRR