dns 1.4.0 → 1.4.1
raw patch · 5 files changed
+19/−22 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.DNS.Types: DNAME :: TYPE
Files
- Network/DNS/Decode.hs +3/−7
- Network/DNS/Internal.hs +9/−9
- Network/DNS/Lookup.hs +1/−1
- Network/DNS/Resolver.hs +5/−4
- dns.cabal +1/−1
Network/DNS/Decode.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, ViewPatterns, DeriveDataTypeable #-}+{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-} module Network.DNS.Decode ( decode@@ -56,16 +56,12 @@ >>= traverse unpackBytes unpackBytes :: RD ByteString -> Either String (RD [Int])-unpackBytes (RD_OTH dta) = fmap (RD_OTH . fst) $ unpack $ dta'+unpackBytes (RD_OTH dta) = RD_OTH . fst <$> unpack dta' where len = fromIntegral $ BS.length dta dta' = BL.fromChunks [dta] unpack = runSGet (getNBytes len)-unpackBytes rd = Right $ cast rd- where- cast = fmap (error "unhandled case in decode")--+unpackBytes rd = Right $ error "unhandled case in decode" <$> rd ---------------------------------------------------------------- receiveDNSFormat :: Source (ResourceT IO) ByteString -> IO (DNSMessage (RD ByteString))
Network/DNS/Internal.hs view
@@ -21,7 +21,7 @@ ---------------------------------------------------------------- -- | Types for resource records.-data TYPE = A | AAAA | NS | TXT | MX | CNAME | SOA | PTR | SRV+data TYPE = A | AAAA | NS | TXT | MX | CNAME | SOA | PTR | SRV | DNAME | UNKNOWN Int deriving (Eq, Show, Read) rrDB :: [(TYPE, Int)]@@ -35,6 +35,7 @@ , (TXT, 16) , (AAAA, 28) , (SRV, 33)+ , (DNAME, 39) -- RFC 2672 ] rookup :: (Eq b) => b -> [(a,b)] -> Maybe a@@ -109,8 +110,7 @@ , authority = auth , additional = add } where- cast = fmap (error "unhandled case in sequenceA (DNSMessage)")- dns+ cast = error "unhandled case in sequenceA (DNSMessage)" <$> dns -- | Like 'fmap' except that RR 'TYPE' context is available -- within the map.@@ -121,11 +121,11 @@ , additional = mapParse $ additional dns } where- cast = fmap (error "unhandled case in dnsMapWithType") dns+ cast = error "unhandled case in dnsMapWithType" <$> dns mapParse = map (rrMapWithType parse) -- | Behaves exactly like a regular 'traverse' except that the traversing--- function also has access to the RR 'TYPE' associated with a value. +-- function also has access to the RR 'TYPE' associated with a value. dnsTraverseWithType :: Applicative f => (TYPE -> a -> f b) -> DNSMessage a -> f (DNSMessage b)@@ -196,10 +196,10 @@ type RDATA = RD [Int] instance Traversable RD where- sequenceA (RD_OTH a) = fmap RD_OTH a+ sequenceA (RD_OTH a) = RD_OTH <$> a sequenceA rd = pure cast where- cast = fmap (error "unhandled case in squenceA (RD)") rd+ cast = error "unhandled case in squenceA (RD)" <$> rd instance Show a => Show (RD a) where show (RD_NS dom) = BS.unpack dom@@ -214,12 +214,12 @@ show (RD_OTH is) = show is instance Traversable RR where- sequenceA rr = fmap (\x -> fmap (const x) rr) $ rdata rr+ sequenceA rr = (\x -> fmap (const x) rr) <$> rdata rr -- | Like 'fmap' except that RR 'TYPE' context is available -- within the map. rrMapWithType :: (TYPE -> a -> b) -> RR a -> RR b-rrMapWithType parse rr = parse (rrtype rr) `fmap` rr+rrMapWithType parse rr = parse (rrtype rr) <$> rr ----------------------------------------------------------------
Network/DNS/Lookup.hs view
@@ -84,7 +84,7 @@ -- >>> -- >>> rs <- makeResolvSeed defaultResolvConf -- >>> withResolver rs $ \resolver -> lookupA resolver hostname--- Right [202.232.15.101]+-- Right [210.130.207.72] -- -- This function will also follow a CNAME and resolve its target if -- one exists for the queries hostname:
Network/DNS/Resolver.hs view
@@ -20,13 +20,14 @@ import Control.Applicative ((<$>), (<*>), pure) import Control.Exception (bracket)-import qualified Data.ByteString.Char8 as BS import Data.Char (isSpace) import Data.List (isPrefixOf)+import Data.Maybe (fromMaybe) import Network.BSD (getProtocolNumber) import Network.DNS.Decode import Network.DNS.Encode import Network.DNS.Internal+import qualified Data.ByteString.Char8 as BS import Network.Socket (HostName, Socket, SocketType(Datagram), sClose, socket, connect) import Network.Socket (AddrInfoFlag(..), AddrInfo(..), SockAddr(..), PortNumber(..), defaultHints, getAddrInfo) import Prelude hiding (lookup)@@ -147,9 +148,9 @@ } a:_ <- getAddrInfo (Just hints) (Just addr) (Just "domain") let connectPort = case addrAddress a of- SockAddrInet pn ha -> SockAddrInet (maybe pn id mport) ha- SockAddrInet6 pn fi ha sid -> SockAddrInet6 (maybe pn id mport) fi ha sid- unix -> unix + SockAddrInet pn ha -> SockAddrInet (fromMaybe pn mport) ha+ SockAddrInet6 pn fi ha sid -> SockAddrInet6 (fromMaybe pn mport) fi ha sid+ unix -> unix return $ a { addrAddress = connectPort } ----------------------------------------------------------------
dns.cabal view
@@ -1,5 +1,5 @@ Name: dns-Version: 1.4.0+Version: 1.4.1 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3