X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fharbl.git;a=blobdiff_plain;f=harbl%2Fsrc%2FNetwork%2FDNS%2FRBL%2FDomain.hs;fp=src%2FNetwork%2FDNS%2FRBL%2FDomain.hs;h=75170a7675bf09ab3c509d41b1ada58b16fbac05;hp=73a69884f826945c1aacca3b118c6c7a389e6693;hb=b55e5db2a68be5d69b970bbe4b5ad447881abd3d;hpb=c4d41b93ec02ff4dc762163441ebefb0324e6f07 diff --git a/src/Network/DNS/RBL/Domain.hs b/harbl/src/Network/DNS/RBL/Domain.hs similarity index 90% rename from src/Network/DNS/RBL/Domain.hs rename to harbl/src/Network/DNS/RBL/Domain.hs index 73a6988..75170a7 100644 --- a/src/Network/DNS/RBL/Domain.hs +++ b/harbl/src/Network/DNS/RBL/Domain.hs @@ -15,8 +15,8 @@ -- (octets). -- module Network.DNS.RBL.Domain ( - UserDomain(..), - user_domain ) + Domain, + domain ) where import Data.Char ( toLower ) @@ -639,8 +639,6 @@ subdomain_has_equal_neighbors s = -- -- We let the 'Domain' type remain true to those RFCs, even though -- they don't support an absolute domain name of e.g. a single dot. --- We have one more data type 'UserDomain' which handles the possibility --- of an absolute path. -- data Domain = DomainName Subdomain | @@ -719,76 +717,3 @@ domain = try parse_subdomain <|> parse_empty parse_empty :: Parser Domain parse_empty = string "" >> return DomainRoot - - - --- * User domains - --- | This type helps clarify some murkiness in the DNS \"domain\" name --- specification. In RFC1034, it is acknowledged that a domain name --- input with a trailing \".\" will represent an absolute domain --- name (i.e. with respect to the DNS root). However, the grammar in --- RFC1035 disallows a trailing dot. --- --- This makes some sense: within the DNS, everything knows its --- position in the tree. The relative/absolute distinction only --- makes sense on the client side, where a user's resolver might --- decide to append some suffix to a relative --- request. Unfortunately, that's where we live. So we have to deal --- with the possibility of having a trailing dot at the end of any --- domain name. --- -data UserDomain = - UserDomainRelative Domain | - UserDomainAbsolute Domain - deriving (Eq, Show) - -instance Pretty UserDomain where - pretty_show (UserDomainRelative d) = pretty_show d - pretty_show (UserDomainAbsolute d) = (pretty_show d) ++ "." - - --- | Parse a 'UserDomain'. This is what we'll be using to read user --- input, since it supports both relative and absolute domain names --- (unlike the implicitly-absolute 'Domain'). --- --- ==== _Examples_ --- --- >>> import Text.Parsec ( parse, parseTest ) --- --- We can really parse the root now! --- --- >>> parseTest user_domain "." --- UserDomainAbsolute DomainRoot --- --- But multiple dots aren't (only the first): --- --- >>> pretty_print $ parse user_domain "" ".." --- . --- --- We can also optionally have a trailing dot at the end of a --- non-empty name: --- --- >>> pretty_print $ parse user_domain "" "www.example.com" --- www.example.com --- --- >>> pretty_print $ parse user_domain "" "www.example.com." --- www.example.com. --- --- A \"relative root\" can also be parsed, letting the user's --- resolver deal with it: --- --- >>> parseTest user_domain "" --- UserDomainRelative DomainRoot --- -user_domain :: Parser UserDomain -user_domain = try absolute <|> relative - where - absolute :: Parser UserDomain - absolute = do - d <- domain - _ <- char '.' - return $ UserDomainAbsolute d - - relative :: Parser UserDomain - relative = fmap UserDomainRelative domain