]> gitweb @ CieloNegro.org - haskell-dns.git/blobdiff - Network/DNS/Message.hs
The server started somewhat working...
[haskell-dns.git] / Network / DNS / Message.hs
index fe595b4942e66686b17003eda1aa1ce4c9426577..9f2b144968c7f394e84068dae3a8cccd84b9b259 100644 (file)
@@ -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