resolv-0.2.0.2: Domain Name Service (DNS) lookup via the libresolv standard library routines

Copyright | © 2017 Herbert Valerio Riedel
License | GPL-2.0-or-later
Safe Haskell | Trustworthy
Language | Haskell2010

Network.DNS

Contents

- High level API
- Mid-level API
- Low-level API
- Types
  - Basic types
    - Names/Labels
    - Character strings
    - IP addresses
    - RR TTL & Class
    - Message types
  - Messages

Description

This module implements an API for accessing the Domain Name Service (DNS) resolver service via the standard `libresolv` system library on Unix systems.

Synopsis

- queryA :: Name -> IO [(TTL, IPv4)]
- queryAAAA :: Name -> IO [(TTL, IPv6)]
- queryCNAME :: Name -> IO [(TTL, Name)]
- queryPTR :: Name -> IO [(TTL, Name)]
- querySRV :: Name -> IO [(TTL, SRV Name)]
- queryTXT :: Name -> IO [(TTL, [CharStr])]
- query :: IsLabels n => Class -> n -> TypeSym -> IO (Msg n)
- data DnsException
  - = DnsEncodeException
  - | DnsDecodeException
  - | DnsHostNotFound
  - | DnsNoData
  - | DnsNoRecovery
  - | DnsTryAgain
- resIsReentrant :: Bool
- queryRaw :: Class -> Name -> Type -> IO ByteString
- sendRaw :: ByteString -> IO ByteString
- mkQueryRaw :: Class -> Name -> Type -> IO ByteString
- decodeMessage :: IsLabels n => ByteString -> Maybe (Msg n)
- encodeMessage :: IsLabels n => Msg n -> Maybe ByteString
- mkQueryMsg :: IsLabels n => Class -> n -> Type -> Msg n
- type Label = ByteString
- data Labels
  - = !Label :.: !Labels
  - | Root
- class IsLabels s where
  - toLabels :: s -> Maybe Labels
  - fromLabels :: Labels -> s
- newtype Name = Name ByteString
- caseFoldName :: Name -> Name
- newtype CharStr = CharStr ByteString
- data IPv4 = IPv4 !Word32
- arpaIPv4 :: IPv4 -> Name
- data IPv6 = IPv6 !Word64 !Word64
- arpaIPv6 :: IPv6 -> Name
- newtype TTL = TTL Int32
- newtype Class = Class Word16
- classIN :: Class
- newtype Type = Type Word16
- data TypeSym
  - = TypeA
  - | TypeAAAA
  - | TypeAFSDB
  - | TypeANY
  - | TypeCAA
  - | TypeCNAME
  - | TypeDNSKEY
  - | TypeDS
  - | TypeHINFO
  - | TypeMX
  - | TypeNAPTR
  - | TypeNS
  - | TypeNSEC
  - | TypeNSEC3
  - | TypeNSEC3PARAM
  - | TypeOPT
  - | TypePTR
  - | TypeRRSIG
  - | TypeSOA
  - | TypeSPF
  - | TypeSRV
  - | TypeSSHFP
  - | TypeTXT
  - | TypeURI
- typeFromSym :: TypeSym -> Type
- typeToSym :: Type -> Maybe TypeSym
- data Msg l = Msg {
  - msgHeader :: !MsgHeader
  - msgQD :: [MsgQuestion l]
  - msgAN :: [MsgRR l]
  - msgNS :: [MsgRR l]
  - msgAR :: [MsgRR l]
  }
- data MsgHeader = MsgHeader {
  - mhId :: !Word16
  - mhFlags :: !MsgHeaderFlags
  - mhQDCount :: !Word16
  - mhANCount :: !Word16
  - mhNSCount :: !Word16
  - mhARCount :: !Word16
  }
- data MsgHeaderFlags = MsgHeaderFlags {
  - mhQR :: !QR
  - mhOpcode :: !Word8
  - mhAA :: !Bool
  - mhTC :: !Bool
  - mhRD :: !Bool
  - mhRA :: !Bool
  - mhZ :: !Bool
  - mhAD :: !Bool
  - mhCD :: !Bool
  - mhRCode :: !Word8
  }
- data QR
  - = IsQuery
  - | IsResponse
- data MsgQuestion l = MsgQuestion !l !Type !Class
- data MsgRR l = MsgRR {
  - rrName :: !l
  - rrClass :: !Class
  - rrTTL :: !TTL
  - rrData :: !(RData l)
  }
- data RData l
  - = RDataA !IPv4
  - | RDataAAAA !IPv6
  - | RDataCNAME !l
  - | RDataPTR !l
  - | RDataHINFO !CharStr !CharStr
  - | RDataNS !l
  - | RDataMX !Word16 !l
  - | RDataTXT ![CharStr]
  - | RDataSPF ![CharStr]
  - | RDataSOA !l !l !Word32 !Word32 !Word32 !Word32 !Word32
  - | RDataSRV !(SRV l)
  - | RDataAFSDB !Word16 !l
  - | RDataNAPTR !Word16 !Word16 !CharStr !CharStr !CharStr !l
  - | RDataURI !Word16 !Word16 !ByteString
  - | RDataRRSIG !Word16 !Word8 !Word8 !Word32 !Word32 !Word32 !Word16 !l !ByteString
  - | RDataDNSKEY !Word16 !Word8 !Word8 !ByteString
  - | RDataDS !Word16 !Word8 !Word8 !ByteString
  - | RDataNSEC !l !(Set Type)
  - | RDataSSHFP !Word8 !Word8 !ByteString
  - | RDataNSEC3PARAM !Word8 !Word8 !Word16 !CharStr
  - | RDataNSEC3 !Word8 !Word8 !Word16 !CharStr !CharStr !(Set Type)
  - | RDataCAA !Word8 !CharStr !ByteString
  - | RDataOPT !ByteString
  - | RData !Type !ByteString
- rdType :: RData l -> Either Type TypeSym
- data SRV l = SRV {
  - srvPriority :: !Word16
  - srvWeight :: !Word16
  - srvPort :: !Word16
  - srvTarget :: !l
  }

## High level API

queryA :: Name -> IO [(TTL, IPv4)] #

Query `A` record (see RFC 1035, section 3.4.1).

This query returns only exact matches (modulo `foldCaseName`). E.g. in case of `CNAME` responses even if the answer section would contain `A` records for the hostnames pointed to by the `CNAME`. You can use `query` if you need more control.

    >>> queryA (Name "www.google.com")
    [(TTL 72,IPv4 0xd83acde4)]

queryAAAA :: Name -> IO [(TTL, IPv6)] #

Query `AAAA` records (see RFC 3596).

This query returns only exact matches (modulo `foldCaseName`). E.g. in case of `CNAME` responses even if the answer section would contain `A` records for the hostnames pointed to by the `CNAME`. You can use `query` if you need more control.

    >>> queryAAAA (Name "www.google.com")
    [(TTL 299,IPv6 0x2a0014504001081e 0x2004)]

queryCNAME :: Name -> IO [(TTL, Name)] #

Query `CNAME` records (see RFC 1035, section 3.3.1).

    >>> queryCNAME (Name "hackage.haskell.org")
    [(TTL 299,Name "j.global-ssl.fastly.net.")]

queryPTR :: Name -> IO [(TTL, Name)] #

Query `PTR` records (see RFC 1035, section 3.3.12).

    >>> queryPTR (Name "4.4.8.8.in-addr.arpa.")
    [(TTL 14390,Name "dns.google.")]

See also `arpaIPv6` and `arpaIPv4` for converting `IPv6` and `IPv4` values to the respective `.arpa."` domain name for reverse lookups.

Since: 0.1.2.0

querySRV :: Name -> IO [(TTL, SRV Name)] #

Query `SRV` records (see RFC 2782).

    >>> querySRV (Name "_imap._tcp.gmail.com")
    [(TTL 21599,SRV {srvPriority = 0, srvWeight = 0, srvPort = 0, srvTarget = Name "."})]

queryTXT :: Name -> IO [(TTL, [CharStr])] #

Query `TXT` records (see RFC 1035, section 3.3.14).

    >>> queryTXT (Name "_mirrors.hackage.haskell.org")
    [(TTL 299,["0.urlbase=http://hackage.fpcomplete.com/",
               "1.urlbase=http://objects-us-west-1.dream.io/hackage-mirror/"])]

# Mid-level API

query :: IsLabels n => Class -> n -> TypeSym -> IO (Msg n) #

Send a query via `res_query(3)` and decode its response into a `Msg`

Throws `DnsException` in case of resolving or encoding/decoding errors. May throw other IO exceptions in case of network errors.

### Example

    >>> query classIN (Name "_mirrors.hackage.haskell.org") TypeTXT
    Just (Msg{msgHeader = MsgHeader{mhId    = 56694,
                                    mhFlags = MsgHeaderFlags{mhQR = IsResponse, mhOpcode = 0, mhAA = False,
                                                             mhTC = False, mhRD = True, mhRA = True, mhZ = False,
                                                             mhAD = False, mhCD = False, mhRCode = 0},
                                    mhQDCount = 1, mhANCount = 1, mhNSCount = 0, mhARCount = 1},
              msgQD = [MsgQuestion (Name "_mirrors.hackage.haskell.org.") (Type 16) (Class 1)],
              msgAN = [MsgRR{rrName  = Name "_mirrors.hackage.haskell.org.",
                             rrClass = Class 1, rrTTL = TTL 299,
                             rrData  = RDataTXT ["0.urlbase=http://hackage.fpcomplete.com/",
                                                 "1.urlbase=http://objects-us-west-1.dream.io/hackage-mirror/"]}],
              msgNS = [],
              msgAR = [MsgRR{rrName = Name ".", rrClass = Class 512, rrTTL = TTL 32768, rrData = RDataOPT ""}]
          })

data DnsException #

Exception thrown in case of errors while resolving or encoding/decoding into a `Msg`.

Since: 0.1.1.0

Constructors

DnsEncodeException |
DnsDecodeException |
DnsHostNotFound | No such domain (authoritative) Since: 0.2.0.0
DnsNoData | No record for requested type Since: 0.2.0.0
DnsNoRecovery | Non recoverable errors, REFUSED, NOTIMP Since: 0.2.0.0
DnsTryAgain | No such domain (non-authoritative) or SERVERFAIL Since: 0.2.0.0

#### Instances

Instances details

Exception DnsException # |
Instance details Defined in Network.DNS Methods toException :: DnsException -> SomeException # fromException :: SomeException -> Maybe DnsException # displayException :: DnsException -> String # backtraceDesired :: DnsException -> Bool #
Show DnsException # |
Instance details Defined in Network.DNS Methods showsPrec :: Int -> DnsException -> ShowS # show :: DnsException -> String # showList :: [DnsException] -> ShowS #

# Low-level API

resIsReentrant :: Bool #

Whether the reentrant DNS resolver C API (e.g. `res_nquery(3)`, `res_nsend(3)`) is being used.

If this this `False`, then as a fall-back `res_query(3)`/`res_send(3)` are used, protected by a global mutex.

Since: 0.1.1.0

queryRaw :: Class -> Name -> Type -> IO ByteString #

Send a query via `res_query(3)`, the return value is the raw binary response message.

You can use `decodeMessage` to decode the response message.

sendRaw :: ByteString -> IO ByteString #

Send a raw preformatted query via `res_send(3)`.

mkQueryRaw :: Class -> Name -> Type -> IO ByteString #

Use `res_mkquery(3)` to construct a DNS query message.

decodeMessage :: IsLabels n => ByteString -> Maybe (Msg n) #

Decode a raw DNS message (query or response)

Returns `Nothing` on decoding failures.

encodeMessage :: IsLabels n => Msg n -> Maybe ByteString #

Construct a raw DNS message (query or response)

May return `Nothing` in input parameters are detected to be invalid.

mkQueryMsg :: IsLabels n => Class -> n -> Type -> Msg n #

Construct a DNS query `Msg` in the style of `mkQueryRaw`

# Types

## Basic types

### Names/Labels

type Label = ByteString #

A DNS Label

Must be non-empty and at most 63 octets.

data Labels #

A `domain-name` as per RFC 1035, section 3.3 expressed as list of `Label`s.

See also `Name`

Constructors

!Label :.: !Labels infixr 5 |
Root |

#### Instances

Instances details

Read Labels # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS Labels # readList :: ReadS [Labels] # readPrec :: ReadPrec Labels # readListPrec :: ReadPrec [Labels] #
Show Labels # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Labels -> ShowS # show :: Labels -> String # showList :: [Labels] -> ShowS #
Eq Labels # |
Instance details Defined in Network.DNS.Message Methods (==) :: Labels -> Labels -> Bool # (/=) :: Labels -> Labels -> Bool #
Ord Labels # |
Instance details Defined in Network.DNS.Message Methods compare :: Labels -> Labels -> Ordering # (<) :: Labels -> Labels -> Bool # (<=) :: Labels -> Labels -> Bool # (>) :: Labels -> Labels -> Bool # (>=) :: Labels -> Labels -> Bool # max :: Labels -> Labels -> Labels # min :: Labels -> Labels -> Labels #
IsLabels Labels # |
Instance details Defined in Network.DNS.Message Methods toLabels :: Labels -> Maybe Labels # fromLabels :: Labels -> Labels #

class IsLabels s where #

Types that represent `domain-name` as per RFC 1035, section 3.3 and can be converted to and from `Labels`.

Methods

toLabels :: s -> Maybe Labels #

fromLabels :: Labels -> s #

#### Instances

Instances details

IsLabels Labels # |
Instance details Defined in Network.DNS.Message Methods toLabels :: Labels -> Maybe Labels # fromLabels :: Labels -> Labels #
IsLabels Name # |
Instance details Defined in Network.DNS.Message Methods toLabels :: Name -> Maybe Labels # fromLabels :: Labels -> Name #

newtype Name #

`<domain-name>` as per RFC 1035, section 3.3.

A domain-name represented as a series of labels separated by dots.

See also `Labels` for list-based representation.

NOTE: The `Labels` type is able to properly represent domain names whose components contain dots which the `Name` representation cannot.

Constructors

Name ByteString |

#### Instances

Instances details

Read Name # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS Name # readList :: ReadS [Name] # readPrec :: ReadPrec Name # readListPrec :: ReadPrec [Name] #
Show Name # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
Eq Name # |
Instance details Defined in Network.DNS.Message Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Ord Name # |
Instance details Defined in Network.DNS.Message Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
IsLabels Name # |
Instance details Defined in Network.DNS.Message Methods toLabels :: Name -> Maybe Labels # fromLabels :: Labels -> Name #

caseFoldName :: Name -> Name #

Normalise `Name`

This function case folds `Name`s as described in in RFC 4343, section 3 by subtracting `0x20` from all octets in the inclusive range `[0x61..0x7A]` (i.e. mapping `[`a`..`z`]` to `[`A`..`Z`]`).

This operation is idempotent.

### Character strings

newtype CharStr #

`<character-string>` as per RFC 1035, section 3.3.

A sequence of up to 255 octets

The limit of 255 octets is caused by the encoding which uses by a prefixed octet denoting the length.

Constructors

CharStr ByteString |

#### Instances

Instances details

Binary CharStr # |
Instance details Defined in Network.DNS.Message Methods put :: CharStr -> Put # get :: Get CharStr # putList :: [CharStr] -> Put #
IsString CharStr # |
Instance details Defined in Network.DNS.Message Methods fromString :: String -> CharStr #
Read CharStr # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS CharStr # readList :: ReadS [CharStr] # readPrec :: ReadPrec CharStr # readListPrec :: ReadPrec [CharStr] #
Show CharStr # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> CharStr -> ShowS # show :: CharStr -> String # showList :: [CharStr] -> ShowS #
Eq CharStr # |
Instance details Defined in Network.DNS.Message Methods (==) :: CharStr -> CharStr -> Bool # (/=) :: CharStr -> CharStr -> Bool #
Ord CharStr # |
Instance details Defined in Network.DNS.Message Methods compare :: CharStr -> CharStr -> Ordering # (<) :: CharStr -> CharStr -> Bool # (<=) :: CharStr -> CharStr -> Bool # (>) :: CharStr -> CharStr -> Bool # (>=) :: CharStr -> CharStr -> Bool # max :: CharStr -> CharStr -> CharStr # min :: CharStr -> CharStr -> CharStr #

### IP addresses

data IPv4 #

An IPv4 address

The IP address is represented in network order, i.e. `127.0.0.1` is represented as `(IPv4 0x7f000001)`.

Constructors

IPv4 !Word32 |

#### Instances

Instances details

Binary IPv4 # |
Instance details Defined in Network.DNS.Message Methods put :: IPv4 -> Put # get :: Get IPv4 # putList :: [IPv4] -> Put #
Read IPv4 # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS IPv4 # readList :: ReadS [IPv4] # readPrec :: ReadPrec IPv4 # readListPrec :: ReadPrec [IPv4] #
Show IPv4 # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> IPv4 -> ShowS # show :: IPv4 -> String # showList :: [IPv4] -> ShowS #
Eq IPv4 # |
Instance details Defined in Network.DNS.Message Methods (==) :: IPv4 -> IPv4 -> Bool # (/=) :: IPv4 -> IPv4 -> Bool #
Ord IPv4 # |
Instance details Defined in Network.DNS.Message Methods compare :: IPv4 -> IPv4 -> Ordering # (<) :: IPv4 -> IPv4 -> Bool # (<=) :: IPv4 -> IPv4 -> Bool # (>) :: IPv4 -> IPv4 -> Bool # (>=) :: IPv4 -> IPv4 -> Bool # max :: IPv4 -> IPv4 -> IPv4 # min :: IPv4 -> IPv4 -> IPv4 #

arpaIPv4 :: IPv4 -> Name #

Convert `IPv4` address to `in-addr.arpa.` `Name` (see RFC 1035, section 3.5).

    >>> arpaIPv4 (IPv4 0x8080404)
    Name "4.4.8.8.in-addr.arpa."

Since: 0.1.2.0

data IPv6 #

An IPv6 address

The IP address is represented in network order, i.e. `2606:2800:220:1:248:1893:25c8:1946` is represented as `(IPv6 0x2606280002200001 0x248189325c81946)`.

Constructors

IPv6 !Word64 !Word64 |

#### Instances

Instances details

Binary IPv6 # |
Instance details Defined in Network.DNS.Message Methods put :: IPv6 -> Put # get :: Get IPv6 # putList :: [IPv6] -> Put #
Read IPv6 # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS IPv6 # readList :: ReadS [IPv6] # readPrec :: ReadPrec IPv6 # readListPrec :: ReadPrec [IPv6] #
Show IPv6 # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> IPv6 -> ShowS # show :: IPv6 -> String # showList :: [IPv6] -> ShowS #
Eq IPv6 # |
Instance details Defined in Network.DNS.Message Methods (==) :: IPv6 -> IPv6 -> Bool # (/=) :: IPv6 -> IPv6 -> Bool #
Ord IPv6 # |
Instance details Defined in Network.DNS.Message Methods compare :: IPv6 -> IPv6 -> Ordering # (<) :: IPv6 -> IPv6 -> Bool # (<=) :: IPv6 -> IPv6 -> Bool # (>) :: IPv6 -> IPv6 -> Bool # (>=) :: IPv6 -> IPv6 -> Bool # max :: IPv6 -> IPv6 -> IPv6 # min :: IPv6 -> IPv6 -> IPv6 #

arpaIPv6 :: IPv6 -> Name #

Convert `IPv4` address to `ip6.arpa.` `Name` (see RFC 3596, section 2.5).

    >>> arpaIPv6 (IPv6 0x2001486048600000 0x8844)
    Name "4.4.8.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.6.8.4.0.6.8.4.1.0.0.2.ip6.arpa."

Since: 0.1.2.0

### RR TTL & Class

newtype TTL #

Cache time-to-live expressed in seconds

Constructors

TTL Int32 |

#### Instances

Instances details

Binary TTL # |
Instance details Defined in Network.DNS.Message Methods put :: TTL -> Put # get :: Get TTL # putList :: [TTL] -> Put #
Read TTL # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS TTL # readList :: ReadS [TTL] # readPrec :: ReadPrec TTL # readListPrec :: ReadPrec [TTL] #
Show TTL # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> TTL -> ShowS # show :: TTL -> String # showList :: [TTL] -> ShowS #
Eq TTL # |
Instance details Defined in Network.DNS.Message Methods (==) :: TTL -> TTL -> Bool # (/=) :: TTL -> TTL -> Bool #
Ord TTL # |
Instance details Defined in Network.DNS.Message Methods compare :: TTL -> TTL -> Ordering # (<) :: TTL -> TTL -> Bool # (<=) :: TTL -> TTL -> Bool # (>) :: TTL -> TTL -> Bool # (>=) :: TTL -> TTL -> Bool # max :: TTL -> TTL -> TTL # min :: TTL -> TTL -> TTL #

newtype Class #

DNS `CLASS` code as per RFC 1035, section 3.2.4

The most commonly used value is `classIN`.

Constructors

Class Word16 |

#### Instances

Instances details

Binary Class # |
Instance details Defined in Network.DNS.Message Methods put :: Class -> Put # get :: Get Class # putList :: [Class] -> Put #
Read Class # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS Class # readList :: ReadS [Class] # readPrec :: ReadPrec Class # readListPrec :: ReadPrec [Class] #
Show Class # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Class -> ShowS # show :: Class -> String # showList :: [Class] -> ShowS #
Eq Class # |
Instance details Defined in Network.DNS.Message Methods (==) :: Class -> Class -> Bool # (/=) :: Class -> Class -> Bool #
Ord Class # |
Instance details Defined in Network.DNS.Message Methods compare :: Class -> Class -> Ordering # (<) :: Class -> Class -> Bool # (<=) :: Class -> Class -> Bool # (>) :: Class -> Class -> Bool # (>=) :: Class -> Class -> Bool # max :: Class -> Class -> Class # min :: Class -> Class -> Class #

classIN :: Class #

The `Class` constant for `IN` (Internet)

### Message types

newtype Type #

Raw DNS record type code

See also `TypeSym`

Constructors

Type Word16 |

#### Instances

Instances details

Binary Type # |
Instance details Defined in Network.DNS.Message Methods put :: Type -> Put # get :: Get Type # putList :: [Type] -> Put #
Read Type # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS Type # readList :: ReadS [Type] # readPrec :: ReadPrec Type # readListPrec :: ReadPrec [Type] #
Show Type # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Type -> ShowS # show :: Type -> String # showList :: [Type] -> ShowS #
Eq Type # |
Instance details Defined in Network.DNS.Message Methods (==) :: Type -> Type -> Bool # (/=) :: Type -> Type -> Bool #
Ord Type # |
Instance details Defined in Network.DNS.Message Methods compare :: Type -> Type -> Ordering # (<) :: Type -> Type -> Bool # (<=) :: Type -> Type -> Bool # (>) :: Type -> Type -> Bool # (>=) :: Type -> Type -> Bool # max :: Type -> Type -> Type # min :: Type -> Type -> Type #

data TypeSym #

Symbolic DNS record type

Constructors

TypeA | RFC 1035
TypeAAAA | RFC 3596
TypeAFSDB | RFC 1183
TypeANY | RFC 1035 (query)
TypeCAA | RFC 6844
TypeCNAME | RFC 1035
TypeDNSKEY | RFC 4034
TypeDS | RFC 4034
TypeHINFO | RFC 1035
TypeMX | RFC 1035
TypeNAPTR | RFC 2915
TypeNS | RFC 1035
TypeNSEC | RFC 4034
TypeNSEC3 | RFC 5155
TypeNSEC3PARAM | RFC 5155
TypeOPT | RFC 6891 (meta)
TypePTR | RFC 1035
TypeRRSIG | RFC 4034
TypeSOA | RFC 1035
TypeSPF | RFC 4408
TypeSRV | RFC 2782
TypeSSHFP | RFC 4255
TypeTXT | RFC 1035
TypeURI | RFC 7553

#### Instances

Instances details

Bounded TypeSym # |
Instance details Defined in Network.DNS.Message Methods minBound :: TypeSym # maxBound :: TypeSym #
Enum TypeSym # |
Instance details Defined in Network.DNS.Message Methods succ :: TypeSym -> TypeSym # pred :: TypeSym -> TypeSym # toEnum :: Int -> TypeSym # fromEnum :: TypeSym -> Int # enumFrom :: TypeSym -> [TypeSym] # enumFromThen :: TypeSym -> TypeSym -> [TypeSym] # enumFromTo :: TypeSym -> TypeSym -> [TypeSym] # enumFromThenTo :: TypeSym -> TypeSym -> TypeSym -> [TypeSym] #
Read TypeSym # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS TypeSym # readList :: ReadS [TypeSym] # readPrec :: ReadPrec TypeSym # readListPrec :: ReadPrec [TypeSym] #
Show TypeSym # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> TypeSym -> ShowS # show :: TypeSym -> String # showList :: [TypeSym] -> ShowS #
Eq TypeSym # |
Instance details Defined in Network.DNS.Message Methods (==) :: TypeSym -> TypeSym -> Bool # (/=) :: TypeSym -> TypeSym -> Bool #
Ord TypeSym # |
Instance details Defined in Network.DNS.Message Methods compare :: TypeSym -> TypeSym -> Ordering # (<) :: TypeSym -> TypeSym -> Bool # (<=) :: TypeSym -> TypeSym -> Bool # (>) :: TypeSym -> TypeSym -> Bool # (>=) :: TypeSym -> TypeSym -> Bool # max :: TypeSym -> TypeSym -> TypeSym # min :: TypeSym -> TypeSym -> TypeSym #

typeFromSym :: TypeSym -> Type #

Convert symbolic `TypeSym` to numeric `Type` code

typeToSym :: Type -> Maybe TypeSym #

Convert `Type` code to symbolic `TypeSym`

## Messages

data Msg l #

Represents a DNS message as per RFC 1035

Constructors

Msg |
Fields msgHeader :: !MsgHeader msgQD :: [MsgQuestion l] msgAN :: [MsgRR l] msgNS :: [MsgRR l] msgAR :: [MsgRR l]

#### Instances

Instances details

Functor Msg # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> Msg a -> Msg b # (<$) :: a -> Msg b -> Msg a #
Foldable Msg # |
Instance details Defined in Network.DNS.Message Methods fold :: Monoid m => Msg m -> m # foldMap :: Monoid m => (a -> m) -> Msg a -> m # foldMap' :: Monoid m => (a -> m) -> Msg a -> m # foldr :: (a -> b -> b) -> b -> Msg a -> b # foldr' :: (a -> b -> b) -> b -> Msg a -> b # foldl :: (b -> a -> b) -> b -> Msg a -> b # foldl' :: (b -> a -> b) -> b -> Msg a -> b # foldr1 :: (a -> a -> a) -> Msg a -> a # foldl1 :: (a -> a -> a) -> Msg a -> a # toList :: Msg a -> [a] # null :: Msg a -> Bool # length :: Msg a -> Int # elem :: Eq a => a -> Msg a -> Bool # maximum :: Ord a => Msg a -> a # minimum :: Ord a => Msg a -> a # sum :: Num a => Msg a -> a # product :: Num a => Msg a -> a #
Traversable Msg # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> Msg a -> f (Msg b) # sequenceA :: Applicative f => Msg (f a) -> f (Msg a) # mapM :: Monad m => (a -> m b) -> Msg a -> m (Msg b) # sequence :: Monad m => Msg (m a) -> m (Msg a) #
Binary l => Binary (Msg l) # |
Instance details Defined in Network.DNS.Message Methods put :: Msg l -> Put # get :: Get (Msg l) # putList :: [Msg l] -> Put #
Read l => Read (Msg l) # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (Msg l) # readList :: ReadS [Msg l] # readPrec :: ReadPrec (Msg l) # readListPrec :: ReadPrec [Msg l] #
Show l => Show (Msg l) # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Msg l -> ShowS # show :: Msg l -> String # showList :: [Msg l] -> ShowS #

data MsgHeader #

DNS message header section as per RFC 1035, section 4.1.1

Constructors

MsgHeader |
Fields mhId :: !Word16 mhFlags :: !MsgHeaderFlags mhQDCount :: !Word16 mhANCount :: !Word16 mhNSCount :: !Word16 mhARCount :: !Word16

#### Instances

Instances details

Binary MsgHeader # |
Instance details Defined in Network.DNS.Message Methods put :: MsgHeader -> Put # get :: Get MsgHeader # putList :: [MsgHeader] -> Put #
Read MsgHeader # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS MsgHeader # readList :: ReadS [MsgHeader] # readPrec :: ReadPrec MsgHeader # readListPrec :: ReadPrec [MsgHeader] #
Show MsgHeader # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgHeader -> ShowS # show :: MsgHeader -> String # showList :: [MsgHeader] -> ShowS #

data MsgHeaderFlags #

DNS message header flags as per RFC 1035, section 4.1.1

Constructors

MsgHeaderFlags |
Fields mhQR :: !QR mhOpcode :: !Word8 mhAA :: !Bool mhTC :: !Bool mhRD :: !Bool mhRA :: !Bool mhZ :: !Bool mhAD :: !Bool mhCD :: !Bool mhRCode :: !Word8

#### Instances

Instances details

Binary MsgHeaderFlags # |
Instance details Defined in Network.DNS.Message Methods put :: MsgHeaderFlags -> Put # get :: Get MsgHeaderFlags # putList :: [MsgHeaderFlags] -> Put #
Read MsgHeaderFlags # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS MsgHeaderFlags # readList :: ReadS [MsgHeaderFlags] # readPrec :: ReadPrec MsgHeaderFlags # readListPrec :: ReadPrec [MsgHeaderFlags] #
Show MsgHeaderFlags # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgHeaderFlags -> ShowS # show :: MsgHeaderFlags -> String # showList :: [MsgHeaderFlags] -> ShowS #

data QR #

Encodes whether message is a query or a response

Since: 0.1.1.0

Constructors

IsQuery |
IsResponse |

#### Instances

Instances details

Read QR # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS QR # readList :: ReadS [QR] # readPrec :: ReadPrec QR # readListPrec :: ReadPrec [QR] #
Show QR # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> QR -> ShowS # show :: QR -> String # showList :: [QR] -> ShowS #
Eq QR # |
Instance details Defined in Network.DNS.Message Methods (==) :: QR -> QR -> Bool # (/=) :: QR -> QR -> Bool #

data MsgQuestion l #

DNS message header section as per RFC 1035, section 4.1.2

Constructors

MsgQuestion !l !Type !Class |

#### Instances

Instances details

Functor MsgQuestion # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> MsgQuestion a -> MsgQuestion b # (<$) :: a -> MsgQuestion b -> MsgQuestion a #
Foldable MsgQuestion # |
Instance details Defined in Network.DNS.Message Methods fold :: Monoid m => MsgQuestion m -> m # foldMap :: Monoid m => (a -> m) -> MsgQuestion a -> m # foldMap' :: Monoid m => (a -> m) -> MsgQuestion a -> m # foldr :: (a -> b -> b) -> b -> MsgQuestion a -> b # foldr' :: (a -> b -> b) -> b -> MsgQuestion a -> b # foldl :: (b -> a -> b) -> b -> MsgQuestion a -> b # foldl' :: (b -> a -> b) -> b -> MsgQuestion a -> b # foldr1 :: (a -> a -> a) -> MsgQuestion a -> a # foldl1 :: (a -> a -> a) -> MsgQuestion a -> a # toList :: MsgQuestion a -> [a] # null :: MsgQuestion a -> Bool # length :: MsgQuestion a -> Int # elem :: Eq a => a -> MsgQuestion a -> Bool # maximum :: Ord a => MsgQuestion a -> a # minimum :: Ord a => MsgQuestion a -> a # sum :: Num a => MsgQuestion a -> a # product :: Num a => MsgQuestion a -> a #
Traversable MsgQuestion # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> MsgQuestion a -> f (MsgQuestion b) # sequenceA :: Applicative f => MsgQuestion (f a) -> f (MsgQuestion a) # mapM :: Monad m => (a -> m b) -> MsgQuestion a -> m (MsgQuestion b) # sequence :: Monad m => MsgQuestion (m a) -> m (MsgQuestion a) #
Binary l => Binary (MsgQuestion l) # |
Instance details Defined in Network.DNS.Message Methods put :: MsgQuestion l -> Put # get :: Get (MsgQuestion l) # putList :: [MsgQuestion l] -> Put #
Read l => Read (MsgQuestion l) # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (MsgQuestion l) # readList :: ReadS [MsgQuestion l] # readPrec :: ReadPrec (MsgQuestion l) # readListPrec :: ReadPrec [MsgQuestion l] #
Show l => Show (MsgQuestion l) # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgQuestion l -> ShowS # show :: MsgQuestion l -> String # showList :: [MsgQuestion l] -> ShowS #
Eq l => Eq (MsgQuestion l) # |
Instance details Defined in Network.DNS.Message Methods (==) :: MsgQuestion l -> MsgQuestion l -> Bool # (/=) :: MsgQuestion l -> MsgQuestion l -> Bool #

data MsgRR l #

DNS resource record section as per RFC 1035, section 4.1.3

Constructors

MsgRR |
Fields rrName :: !l rrClass :: !Class rrTTL :: !TTL rrData :: !(RData l)

#### Instances

Instances details

Functor MsgRR # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> MsgRR a -> MsgRR b # (<$) :: a -> MsgRR b -> MsgRR a #
Foldable MsgRR # |
Instance details Defined in Network.DNS.Message Methods fold :: Monoid m => MsgRR m -> m # foldMap :: Monoid m => (a -> m) -> MsgRR a -> m # foldMap' :: Monoid m => (a -> m) -> MsgRR a -> m # foldr :: (a -> b -> b) -> b -> MsgRR a -> b # foldr' :: (a -> b -> b) -> b -> MsgRR a -> b # foldl :: (b -> a -> b) -> b -> MsgRR a -> b # foldl' :: (b -> a -> b) -> b -> MsgRR a -> b # foldr1 :: (a -> a -> a) -> MsgRR a -> a # foldl1 :: (a -> a -> a) -> MsgRR a -> a # toList :: MsgRR a -> [a] # null :: MsgRR a -> Bool # length :: MsgRR a -> Int # elem :: Eq a => a -> MsgRR a -> Bool # maximum :: Ord a => MsgRR a -> a # minimum :: Ord a => MsgRR a -> a # sum :: Num a => MsgRR a -> a # product :: Num a => MsgRR a -> a #
Traversable MsgRR # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> MsgRR a -> f (MsgRR b) # sequenceA :: Applicative f => MsgRR (f a) -> f (MsgRR a) # mapM :: Monad m => (a -> m b) -> MsgRR a -> m (MsgRR b) # sequence :: Monad m => MsgRR (m a) -> m (MsgRR a) #
Binary l => Binary (MsgRR l) # |
Instance details Defined in Network.DNS.Message Methods put :: MsgRR l -> Put # get :: Get (MsgRR l) # putList :: [MsgRR l] -> Put #
Read l => Read (MsgRR l) # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (MsgRR l) # readList :: ReadS [MsgRR l] # readPrec :: ReadPrec (MsgRR l) # readListPrec :: ReadPrec [MsgRR l] #
Show l => Show (MsgRR l) # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgRR l -> ShowS # show :: MsgRR l -> String # showList :: [MsgRR l] -> ShowS #
Eq l => Eq (MsgRR l) # |
Instance details Defined in Network.DNS.Message Methods (==) :: MsgRR l -> MsgRR l -> Bool # (/=) :: MsgRR l -> MsgRR l -> Bool #

data RData l #

DNS resource record data (see also `MsgRR` and `TypeSym`)

Constructors

RDataA !IPv4 |
RDataAAAA !IPv6 |
RDataCNAME !l |
RDataPTR !l |
RDataHINFO !CharStr !CharStr |
RDataNS !l |
RDataMX !Word16 !l |
RDataTXT ![CharStr] |
RDataSPF ![CharStr] |
RDataSOA !l !l !Word32 !Word32 !Word32 !Word32 !Word32 |
RDataSRV !(SRV l) |
RDataAFSDB !Word16 !l |
RDataNAPTR !Word16 !Word16 !CharStr !CharStr !CharStr !l |
RDataURI !Word16 !Word16 !ByteString |
RDataRRSIG !Word16 !Word8 !Word8 !Word32 !Word32 !Word32 !Word16 !l !ByteString |
RDataDNSKEY !Word16 !Word8 !Word8 !ByteString |
RDataDS !Word16 !Word8 !Word8 !ByteString |
RDataNSEC !l !(Set Type) |
RDataSSHFP !Word8 !Word8 !ByteString |
RDataNSEC3PARAM !Word8 !Word8 !Word16 !CharStr |
RDataNSEC3 !Word8 !Word8 !Word16 !CharStr !CharStr !(Set Type) |
RDataCAA !Word8 !CharStr !ByteString |
RDataOPT !ByteString |
RData !Type !ByteString | Unknown/undecoded resource record type

#### Instances

Instances details

Functor RData # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> RData a -> RData b # (<$) :: a -> RData b -> RData a #
Foldable RData # |
Instance details Defined in Network.DNS.Message Methods fold :: Monoid m => RData m -> m # foldMap :: Monoid m => (a -> m) -> RData a -> m # foldMap' :: Monoid m => (a -> m) -> RData a -> m # foldr :: (a -> b -> b) -> b -> RData a -> b # foldr' :: (a -> b -> b) -> b -> RData a -> b # foldl :: (b -> a -> b) -> b -> RData a -> b # foldl' :: (b -> a -> b) -> b -> RData a -> b # foldr1 :: (a -> a -> a) -> RData a -> a # foldl1 :: (a -> a -> a) -> RData a -> a # toList :: RData a -> [a] # null :: RData a -> Bool # length :: RData a -> Int # elem :: Eq a => a -> RData a -> Bool # maximum :: Ord a => RData a -> a # minimum :: Ord a => RData a -> a # sum :: Num a => RData a -> a # product :: Num a => RData a -> a #
Traversable RData # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> RData a -> f (RData b) # sequenceA :: Applicative f => RData (f a) -> f (RData a) # mapM :: Monad m => (a -> m b) -> RData a -> m (RData b) # sequence :: Monad m => RData (m a) -> m (RData a) #
Read l => Read (RData l) # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (RData l) # readList :: ReadS [RData l] # readPrec :: ReadPrec (RData l) # readListPrec :: ReadPrec [RData l] #
Show l => Show (RData l) # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> RData l -> ShowS # show :: RData l -> String # showList :: [RData l] -> ShowS #
Eq l => Eq (RData l) # |
Instance details Defined in Network.DNS.Message Methods (==) :: RData l -> RData l -> Bool # (/=) :: RData l -> RData l -> Bool #

rdType :: RData l -> Either Type TypeSym #

Extract the resource record type of a `RData` object

data SRV l #

`SRV` Record data as per RFC 2782

Constructors

SRV |
Fields srvPriority :: !Word16 srvWeight :: !Word16 srvPort :: !Word16 srvTarget :: !l

#### Instances

Instances details

Functor SRV # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> SRV a -> SRV b # (<$) :: a -> SRV b -> SRV a #
Foldable SRV # |
Instance details Defined in Network.DNS.Message Methods fold :: Monoid m => SRV m -> m # foldMap :: Monoid m => (a -> m) -> SRV a -> m # foldMap' :: Monoid m => (a -> m) -> SRV a -> m # foldr :: (a -> b -> b) -> b -> SRV a -> b # foldr' :: (a -> b -> b) -> b -> SRV a -> b # foldl :: (b -> a -> b) -> b -> SRV a -> b # foldl' :: (b -> a -> b) -> b -> SRV a -> b # foldr1 :: (a -> a -> a) -> SRV a -> a # foldl1 :: (a -> a -> a) -> SRV a -> a # toList :: SRV a -> [a] # null :: SRV a -> Bool # length :: SRV a -> Int # elem :: Eq a => a -> SRV a -> Bool # maximum :: Ord a => SRV a -> a # minimum :: Ord a => SRV a -> a # sum :: Num a => SRV a -> a # product :: Num a => SRV a -> a #
Traversable SRV # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> SRV a -> f (SRV b) # sequenceA :: Applicative f => SRV (f a) -> f (SRV a) # mapM :: Monad m => (a -> m b) -> SRV a -> m (SRV b) # sequence :: Monad m => SRV (m a) -> m (SRV a) #
Binary l => Binary (SRV l) # |
Instance details Defined in Network.DNS.Message Methods put :: SRV l -> Put # get :: Get (SRV l) # putList :: [SRV l] -> Put #
Read l => Read (SRV l) # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (SRV l) # readList :: ReadS [SRV l] # readPrec :: ReadPrec (SRV l) # readListPrec :: ReadPrec [SRV l] #
Show l => Show (SRV l) # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> SRV l -> ShowS # show :: SRV l -> String # showList :: [SRV l] -> ShowS #
Eq l => Eq (SRV l) # |
Instance details Defined in Network.DNS.Message Methods (==) :: SRV l -> SRV l -> Bool # (/=) :: SRV l -> SRV l -> Bool #