resolv-0.2.0.3: 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)] Source #

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)] Source #

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)] Source #

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)] Source #

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)] Source #

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])] Source #

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) Source #

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 Source #

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 Source # |
Instance details Defined in Network.DNS Methods toException :: DnsException -> SomeException Source # fromException :: SomeException -> Maybe DnsException Source # displayException :: DnsException -> String Source # backtraceDesired :: DnsException -> Bool Source #
Show DnsException Source # |
Instance details Defined in Network.DNS Methods showsPrec :: Int -> DnsException -> ShowS Source # show :: DnsException -> String Source # showList :: [DnsException] -> ShowS Source #
Eq DnsException Source # |
Instance details Defined in Network.DNS Methods (==) :: DnsException -> DnsException -> Bool Source # (/=) :: DnsException -> DnsException -> Bool Source #

# Low-level API

resIsReentrant :: Bool Source #

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 Source #

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 Source #

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

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

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

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

Decode a raw DNS message (query or response)

Returns `Nothing` on decoding failures.

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

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 Source #

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

# Types

## Basic types

### Names/Labels

type Label = ByteString Source #

A DNS Label

Must be non-empty and at most 63 octets.

data Labels Source #

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

class IsLabels s where Source #

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 Source #

fromLabels :: Labels -> s Source #

#### Instances

Instances details

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

newtype Name Source #

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

caseFoldName :: Name -> Name Source #

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 Source #

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

### IP addresses

data IPv4 Source #

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

arpaIPv4 :: IPv4 -> Name Source #

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 Source #

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

arpaIPv6 :: IPv6 -> Name Source #

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 Source #

Cache time-to-live expressed in seconds

Constructors

TTL Int32 |

#### Instances

Instances details

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

newtype Class Source #

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

classIN :: Class Source #

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

### Message types

newtype Type Source #

Raw DNS record type code

See also `TypeSym`

Constructors

Type Word16 |

#### Instances

Instances details

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

data TypeSym Source #

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 Source # |
Instance details Defined in Network.DNS.Message Methods minBound :: TypeSym Source # maxBound :: TypeSym Source #
Enum TypeSym Source # |

Instance details

Defined in Network.DNS.Message

Methods

succ :: TypeSym -> TypeSym Source #

pred :: TypeSym -> TypeSym Source #

toEnum :: Int -> TypeSym Source #

fromEnum :: TypeSym -> Int Source #

enumFrom :: TypeSym -> [TypeSym] Source #

enumFromThen :: TypeSym -> TypeSym -> [TypeSym] Source #

enumFromTo :: TypeSym -> TypeSym -> [TypeSym] Source #

enumFromThenTo :: TypeSym -> TypeSym -> TypeSym -> [TypeSym] Source #

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

typeFromSym :: TypeSym -> Type Source #

Convert symbolic `TypeSym` to numeric `Type` code

typeToSym :: Type -> Maybe TypeSym Source #

Convert `Type` code to symbolic `TypeSym`

## Messages

data Msg l Source #

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 Source # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> Msg a -> Msg b Source # (<$) :: a -> Msg b -> Msg a Source #
Foldable Msg Source # |

Instance details

Defined in Network.DNS.Message

Methods

fold :: Monoid m => Msg m -> m Source #

foldMap :: Monoid m => (a -> m) -> Msg a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Msg a -> m Source #

foldr :: (a -> b -> b) -> b -> Msg a -> b Source #

foldr' :: (a -> b -> b) -> b -> Msg a -> b Source #

foldl :: (b -> a -> b) -> b -> Msg a -> b Source #

foldl' :: (b -> a -> b) -> b -> Msg a -> b Source #

foldr1 :: (a -> a -> a) -> Msg a -> a Source #

foldl1 :: (a -> a -> a) -> Msg a -> a Source #

toList :: Msg a -> [a] Source #

null :: Msg a -> Bool Source #

length :: Msg a -> Int Source #

elem :: Eq a => a -> Msg a -> Bool Source #

maximum :: Ord a => Msg a -> a Source #

minimum :: Ord a => Msg a -> a Source #

sum :: Num a => Msg a -> a Source #

product :: Num a => Msg a -> a Source #

Traversable Msg Source # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> Msg a -> f (Msg b) Source # sequenceA :: Applicative f => Msg (f a) -> f (Msg a) Source # mapM :: Monad m => (a -> m b) -> Msg a -> m (Msg b) Source # sequence :: Monad m => Msg (m a) -> m (Msg a) Source #
Binary l => Binary (Msg l) Source # |
Instance details Defined in Network.DNS.Message Methods put :: Msg l -> Put Source # get :: Get (Msg l) Source # putList :: [Msg l] -> Put Source #
Read l => Read (Msg l) Source # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (Msg l) Source # readList :: ReadS [Msg l] Source # readPrec :: ReadPrec (Msg l) Source # readListPrec :: ReadPrec [Msg l] Source #
Show l => Show (Msg l) Source # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> Msg l -> ShowS Source # show :: Msg l -> String Source # showList :: [Msg l] -> ShowS Source #

data MsgHeader Source #

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

data MsgHeaderFlags Source #

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

data QR Source #

Encodes whether message is a query or a response

Since: 0.1.1.0

Constructors

IsQuery |
IsResponse |

#### Instances

Instances details

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

data MsgQuestion l Source #

DNS message header section as per RFC 1035, section 4.1.2

Constructors

MsgQuestion !l !Type !Class |

#### Instances

Instances details

Functor MsgQuestion Source # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> MsgQuestion a -> MsgQuestion b Source # (<$) :: a -> MsgQuestion b -> MsgQuestion a Source #
Foldable MsgQuestion Source # |

Instance details

Defined in Network.DNS.Message

Methods

fold :: Monoid m => MsgQuestion m -> m Source #

foldMap :: Monoid m => (a -> m) -> MsgQuestion a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MsgQuestion a -> m Source #

foldr :: (a -> b -> b) -> b -> MsgQuestion a -> b Source #

foldr' :: (a -> b -> b) -> b -> MsgQuestion a -> b Source #

foldl :: (b -> a -> b) -> b -> MsgQuestion a -> b Source #

foldl' :: (b -> a -> b) -> b -> MsgQuestion a -> b Source #

foldr1 :: (a -> a -> a) -> MsgQuestion a -> a Source #

foldl1 :: (a -> a -> a) -> MsgQuestion a -> a Source #

toList :: MsgQuestion a -> [a] Source #

null :: MsgQuestion a -> Bool Source #

length :: MsgQuestion a -> Int Source #

elem :: Eq a => a -> MsgQuestion a -> Bool Source #

maximum :: Ord a => MsgQuestion a -> a Source #

minimum :: Ord a => MsgQuestion a -> a Source #

sum :: Num a => MsgQuestion a -> a Source #

product :: Num a => MsgQuestion a -> a Source #

Traversable MsgQuestion Source # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> MsgQuestion a -> f (MsgQuestion b) Source # sequenceA :: Applicative f => MsgQuestion (f a) -> f (MsgQuestion a) Source # mapM :: Monad m => (a -> m b) -> MsgQuestion a -> m (MsgQuestion b) Source # sequence :: Monad m => MsgQuestion (m a) -> m (MsgQuestion a) Source #
Binary l => Binary (MsgQuestion l) Source # |
Instance details Defined in Network.DNS.Message Methods put :: MsgQuestion l -> Put Source # get :: Get (MsgQuestion l) Source # putList :: [MsgQuestion l] -> Put Source #
Read l => Read (MsgQuestion l) Source # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (MsgQuestion l) Source # readList :: ReadS [MsgQuestion l] Source # readPrec :: ReadPrec (MsgQuestion l) Source # readListPrec :: ReadPrec [MsgQuestion l] Source #
Show l => Show (MsgQuestion l) Source # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgQuestion l -> ShowS Source # show :: MsgQuestion l -> String Source # showList :: [MsgQuestion l] -> ShowS Source #
Eq l => Eq (MsgQuestion l) Source # |
Instance details Defined in Network.DNS.Message Methods (==) :: MsgQuestion l -> MsgQuestion l -> Bool Source # (/=) :: MsgQuestion l -> MsgQuestion l -> Bool Source #

data MsgRR l Source #

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 Source # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> MsgRR a -> MsgRR b Source # (<$) :: a -> MsgRR b -> MsgRR a Source #
Foldable MsgRR Source # |

Instance details

Defined in Network.DNS.Message

Methods

fold :: Monoid m => MsgRR m -> m Source #

foldMap :: Monoid m => (a -> m) -> MsgRR a -> m Source #

foldMap' :: Monoid m => (a -> m) -> MsgRR a -> m Source #

foldr :: (a -> b -> b) -> b -> MsgRR a -> b Source #

foldr' :: (a -> b -> b) -> b -> MsgRR a -> b Source #

foldl :: (b -> a -> b) -> b -> MsgRR a -> b Source #

foldl' :: (b -> a -> b) -> b -> MsgRR a -> b Source #

foldr1 :: (a -> a -> a) -> MsgRR a -> a Source #

foldl1 :: (a -> a -> a) -> MsgRR a -> a Source #

toList :: MsgRR a -> [a] Source #

null :: MsgRR a -> Bool Source #

length :: MsgRR a -> Int Source #

elem :: Eq a => a -> MsgRR a -> Bool Source #

maximum :: Ord a => MsgRR a -> a Source #

minimum :: Ord a => MsgRR a -> a Source #

sum :: Num a => MsgRR a -> a Source #

product :: Num a => MsgRR a -> a Source #

Traversable MsgRR Source # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> MsgRR a -> f (MsgRR b) Source # sequenceA :: Applicative f => MsgRR (f a) -> f (MsgRR a) Source # mapM :: Monad m => (a -> m b) -> MsgRR a -> m (MsgRR b) Source # sequence :: Monad m => MsgRR (m a) -> m (MsgRR a) Source #
Binary l => Binary (MsgRR l) Source # |
Instance details Defined in Network.DNS.Message Methods put :: MsgRR l -> Put Source # get :: Get (MsgRR l) Source # putList :: [MsgRR l] -> Put Source #
Read l => Read (MsgRR l) Source # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (MsgRR l) Source # readList :: ReadS [MsgRR l] Source # readPrec :: ReadPrec (MsgRR l) Source # readListPrec :: ReadPrec [MsgRR l] Source #
Show l => Show (MsgRR l) Source # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> MsgRR l -> ShowS Source # show :: MsgRR l -> String Source # showList :: [MsgRR l] -> ShowS Source #
Eq l => Eq (MsgRR l) Source # |
Instance details Defined in Network.DNS.Message Methods (==) :: MsgRR l -> MsgRR l -> Bool Source # (/=) :: MsgRR l -> MsgRR l -> Bool Source #

data RData l Source #

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 Source # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> RData a -> RData b Source # (<$) :: a -> RData b -> RData a Source #
Foldable RData Source # |

Instance details

Defined in Network.DNS.Message

Methods

fold :: Monoid m => RData m -> m Source #

foldMap :: Monoid m => (a -> m) -> RData a -> m Source #

foldMap' :: Monoid m => (a -> m) -> RData a -> m Source #

foldr :: (a -> b -> b) -> b -> RData a -> b Source #

foldr' :: (a -> b -> b) -> b -> RData a -> b Source #

foldl :: (b -> a -> b) -> b -> RData a -> b Source #

foldl' :: (b -> a -> b) -> b -> RData a -> b Source #

foldr1 :: (a -> a -> a) -> RData a -> a Source #

foldl1 :: (a -> a -> a) -> RData a -> a Source #

toList :: RData a -> [a] Source #

null :: RData a -> Bool Source #

length :: RData a -> Int Source #

elem :: Eq a => a -> RData a -> Bool Source #

maximum :: Ord a => RData a -> a Source #

minimum :: Ord a => RData a -> a Source #

sum :: Num a => RData a -> a Source #

product :: Num a => RData a -> a Source #

Traversable RData Source # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> RData a -> f (RData b) Source # sequenceA :: Applicative f => RData (f a) -> f (RData a) Source # mapM :: Monad m => (a -> m b) -> RData a -> m (RData b) Source # sequence :: Monad m => RData (m a) -> m (RData a) Source #
Read l => Read (RData l) Source # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (RData l) Source # readList :: ReadS [RData l] Source # readPrec :: ReadPrec (RData l) Source # readListPrec :: ReadPrec [RData l] Source #
Show l => Show (RData l) Source # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> RData l -> ShowS Source # show :: RData l -> String Source # showList :: [RData l] -> ShowS Source #
Eq l => Eq (RData l) Source # |
Instance details Defined in Network.DNS.Message Methods (==) :: RData l -> RData l -> Bool Source # (/=) :: RData l -> RData l -> Bool Source #

rdType :: RData l -> Either Type TypeSym Source #

Extract the resource record type of a `RData` object

data SRV l Source #

`SRV` Record data as per RFC 2782

Constructors

SRV |

Fields

- srvPriority :: !Word16
- srvWeight :: !Word16
- srvPort :: !Word16
- srvTarget :: !l

#### Instances

Instances details

Functor SRV Source # |
Instance details Defined in Network.DNS.Message Methods fmap :: (a -> b) -> SRV a -> SRV b Source # (<$) :: a -> SRV b -> SRV a Source #
Foldable SRV Source # |

Instance details

Defined in Network.DNS.Message

Methods

fold :: Monoid m => SRV m -> m Source #

foldMap :: Monoid m => (a -> m) -> SRV a -> m Source #

foldMap' :: Monoid m => (a -> m) -> SRV a -> m Source #

foldr :: (a -> b -> b) -> b -> SRV a -> b Source #

foldr' :: (a -> b -> b) -> b -> SRV a -> b Source #

foldl :: (b -> a -> b) -> b -> SRV a -> b Source #

foldl' :: (b -> a -> b) -> b -> SRV a -> b Source #

foldr1 :: (a -> a -> a) -> SRV a -> a Source #

foldl1 :: (a -> a -> a) -> SRV a -> a Source #

toList :: SRV a -> [a] Source #

null :: SRV a -> Bool Source #

length :: SRV a -> Int Source #

elem :: Eq a => a -> SRV a -> Bool Source #

maximum :: Ord a => SRV a -> a Source #

minimum :: Ord a => SRV a -> a Source #

sum :: Num a => SRV a -> a Source #

product :: Num a => SRV a -> a Source #

Traversable SRV Source # |
Instance details Defined in Network.DNS.Message Methods traverse :: Applicative f => (a -> f b) -> SRV a -> f (SRV b) Source # sequenceA :: Applicative f => SRV (f a) -> f (SRV a) Source # mapM :: Monad m => (a -> m b) -> SRV a -> m (SRV b) Source # sequence :: Monad m => SRV (m a) -> m (SRV a) Source #
Binary l => Binary (SRV l) Source # |
Instance details Defined in Network.DNS.Message Methods put :: SRV l -> Put Source # get :: Get (SRV l) Source # putList :: [SRV l] -> Put Source #
Read l => Read (SRV l) Source # |
Instance details Defined in Network.DNS.Message Methods readsPrec :: Int -> ReadS (SRV l) Source # readList :: ReadS [SRV l] Source # readPrec :: ReadPrec (SRV l) Source # readListPrec :: ReadPrec [SRV l] Source #
Show l => Show (SRV l) Source # |
Instance details Defined in Network.DNS.Message Methods showsPrec :: Int -> SRV l -> ShowS Source # show :: SRV l -> String Source # showList :: [SRV l] -> ShowS Source #
Eq l => Eq (SRV l) Source # |
Instance details Defined in Network.DNS.Message Methods (==) :: SRV l -> SRV l -> Bool Source # (/=) :: SRV l -> SRV l -> Bool Source #