| Copyright | (c) Viktor Dukhovni 2026 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | ietf-dane@dukhovni.org |
| Stability | unstable |
| Safe Haskell | None |
| Language | GHC2024 |
Net.DNSBase
Description
A DNS stub-resolver library with a typed RData model and a
runtime extension API. The IO layer is derived from Kazu
Yamamoto's dns
package; what dnsbase layers on top sits in the RR-data model
and the configuration story.
Every RR type's payload is modeled via a dedicated Haskell type
— these include, for example, the recent SVCB / HTTPS
service-binding records, with up-to-date extensible SvcParam
coverage. EDNS option support includes Extended DNS Errors
(EDE) with a user-extensible info-code name table. Coverage of
both widely used and historical DNS RR types is comprehensive —
only the most marginal obsolete or experimental types remain
unimplemented. Individual payloads are held uniformly inside
the existential RData wrapper, so an RR value can carry any
type's data.
The basic lookup interface (lookupA, lookupMX, lookupTXT,
…) is deliberately similar to dns; the differences are
concentrated in the typed-data layer and the configuration
surface.
Extending the library
Applications can extend the library with any missing RRTYPEs, EDNS(0) options, or SVCB and HTTPS service parameter values. Application-specified data types take precedence over any existing or later added built-in implementations.
Extensions are registered by constructing a pure resolver configuration value, rather than via IO actions on mutable global state. Adding custom data types to the library does not require a source-code fork. See Adding a custom RR type and Adding a custom EDNS option for detailed examples.
Concurrency
Like its dns ancestor, dnsbase scales well to thousands of
forkIO threads, with throughput of around ten thousand
distinct queries (not even cache hits) per second observed when
given sufficient concurrency, a high file descriptor limit and
a cooperative upstream iterative resolver.
A single ResolvSeed configuration can be used to derive
per-thread Resolver instances via withResolver. As in
dns, concurrent use of the same Resolver in multiple
threads is not supported.
A minimal example
import Net.DNSBase
import Control.Exception (throwIO)
import System.IO (stdout)
main :: IO ()
main = makeResolvSeed defaultResolvConf >>= \ case
Left e -> throwIO e
Right seed -> withResolver seed \ r ->
lookupMX r $$(dnLit8 "ietf.org") >>= \ case
Left e -> throwIO e
Right mxs -> hPutBuilder stdout $ foldr presentLn mempty mxsmakeResolvSeed builds a ResolvSeed from a ResolverConf; the
default reads /etc/resolv.conf. The setters:
compose with defaultResolvConf to override individual fields.
Inside a withResolver block the per-RRtype lookup combinators,
such as:
each return a list of matching records. Applications that want
to process the full DNSMessage response can use lookupRaw
or lookupRawCtl.
The dnLit and dnLit8 Template-Haskell splices make it
possible to validate a literal domain name at compile time.
The idna2008 package provides compatible parsers for Unicode
internationalised domain names (IDNs).
Module tour
This all-in-one module re-exports almost the entire public API. Specific topics are covered in:
- Resolver setup and queries — Net.DNSBase.Resolver, Net.DNSBase.Lookup.
- Domain names — Net.DNSBase.Domain.
- Resource-record types and the
RDatawrapper — Net.DNSBase.RR, Net.DNSBase.RData, Net.DNSBase.RRTYPE, Net.DNSBase.RRCLASS. - Address records — Net.DNSBase.RData.A.
- Name-valued records (CNAME, NS, PTR, etc.) — Net.DNSBase.RData.XNAME.
- Mail and service records (SOA, RP, MX, SRV, NAPTR, etc.) — Net.DNSBase.RData.SOA, Net.DNSBase.RData.SRV.
- Service-binding records (SVCB, HTTPS) — Net.DNSBase.RData.SVCB.
- DNSSEC (DS, DNSKEY, RRSIG, etc.) and denial of existence (NSEC, NSEC3, …) — Net.DNSBase.RData.Dnssec, Net.DNSBase.RData.NSEC.
- DANE certificate bindings (TLSA, SMIMEA, SSHFP, OPENPGPKEY) — Net.DNSBase.RData.TLSA.
- Other RR types (TXT, CAA, CSYNC, etc.) — the corresponding
Net.DNSBase.RData.*submodules. - EDNS options — Net.DNSBase.EDNS, Net.DNSBase.EDNS.Option and the per-option submodules.
- DNS message structure — Net.DNSBase.Message.
- Extending the library at runtime —
Net.DNSBase.Extensible (long-form guide),
Net.DNSBase.Resolver (the
registerandextendcombinators).
Synopsis
- data ResolverConf
- defaultResolvConf :: ResolverConf
- data NameserverConf
- data NameserverSpec = NameserverSpec {}
- data ResolvSeed
- makeResolvSeed :: ResolverConf -> IO (Either DNSError ResolvSeed)
- data Resolver
- withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO a
- type Lookup a = Resolver -> Domain -> IO (Either DNSError [a])
- extractAnswers :: DNSMessage -> IO (Either DNSError [RR])
- lookupRaw :: Resolver -> Domain -> RRCLASS -> RRTYPE -> IO (Either DNSError DNSMessage)
- lookupRawCtl :: Resolver -> QueryControls -> Domain -> RRCLASS -> RRTYPE -> IO (Either DNSError DNSMessage)
- lookupAnswers :: Resolver -> QueryControls -> RRCLASS -> RRTYPE -> Domain -> IO (Either DNSError [RR])
- lookupA :: Lookup IPv4
- lookupAAAA :: Lookup IPv6
- lookupMX :: Lookup T_mx
- lookupNS :: Lookup Domain
- lookupCNAME :: Lookup Domain
- lookupPTR :: Lookup Domain
- lookupTXT :: Lookup (NonEmpty ShortByteString)
- lookupSOA :: Lookup T_soa
- lookupSRV :: Lookup T_srv
- lookupTLSA :: Lookup T_tlsa
- lookupHTTPS :: Lookup T_https
- data Domain where
- pattern RootDomain :: Domain
- dnLit :: forall e (m :: Type -> Type). (Show e, MonadFail m, Quote m) => (Text -> Either e ShortByteString) -> String -> Code m Domain
- decodePresentationDomain :: (Text -> Either e ShortByteString) -> Text -> Either (Maybe e) Domain
- dnLit8 :: forall (m :: Type -> Type). (Quote m, MonadFail m) => String -> Code m Domain
- makeDomain8 :: ByteString -> Either Domain8Err Domain
- makeDomain8Str :: String -> Either Domain8Err Domain
- shortBytes :: Domain -> ShortByteString
- wireToDomain :: ShortByteString -> Maybe Domain
- data RR = RR {}
- data DnsTriple = DnsTriple {}
- data RData
- fromRData :: KnownRData a => RData -> Maybe a
- data RRTYPE
- data RRCLASS
- data DNSMessage
- data DNSError
- newtype T_a = T_A IPv4
- newtype T_aaaa = T_AAAA IPv6
- data T_mx = T_MX {}
- data T_srv = T_SRV {}
- newtype T_txt = T_TXT (NonEmpty ShortByteString)
- type T_ptr = X_domain N_ptr
- pattern T_PTR :: Domain -> T_ptr
- type T_https = X_svcb N_https
- pattern T_HTTPS :: Word16 -> Domain -> SPVSet -> T_https
- data QueryControls where
- pattern QctlFlags :: (FlagOps -> FlagOps) -> QueryControls
- pattern EdnsEnabled :: QueryControls
- pattern EdnsDisabled :: QueryControls
- pattern EdnsUdpSize :: Word16 -> QueryControls
- pattern EdnsOptionCtl :: (OptionCtl -> OptionCtl) -> QueryControls
- pattern RDflag :: DNSFlags
- pattern ADflag :: DNSFlags
- pattern CDflag :: DNSFlags
- pattern DOflag :: DNSFlags
- setFlagBits :: DNSFlags -> FlagOps -> FlagOps
- clearFlagBits :: DNSFlags -> FlagOps -> FlagOps
- class (Typeable a, Eq a, Ord a, Show a, Presentable a) => KnownRData a
- registerRRtype :: forall a -> KnownRData a => ResolverConf -> ResolverConf
- extendRRwithType :: forall t -> (KnownRData t, TypeExtensible t (RDataExtensionVal t)) => forall b -> TypeExtensionArg t b => ResolverConf -> ResolverConf
- extendRRwithValue :: forall t -> (KnownRData t, ValueExtensible t (RDataExtensionVal t)) => forall b. ValueExtensionArg t b => b -> ResolverConf -> ResolverConf
- class (Typeable a, Eq a, Show a, Presentable a) => KnownEdnsOption a
- registerEdnsOption :: forall a -> KnownEdnsOption a => ResolverConf -> ResolverConf
- extendEdnsOptionWithType :: forall t -> (KnownEdnsOption t, TypeExtensible t (OptionExtensionVal t)) => forall b -> TypeExtensionArg t b => ResolverConf -> ResolverConf
- extendEdnsOptionWithValue :: forall t -> (KnownEdnsOption t, ValueExtensible t (OptionExtensionVal t)) => forall b. ValueExtensionArg t b => b -> ResolverConf -> ResolverConf
- class (Typeable a, Eq a, Ord a, Show a, Presentable a) => KnownSVCParamValue a
- class TypeExtensible a v where
- type TypeExtensionArg a b
- extendByType :: forall t b -> (t ~ a, TypeExtensionArg t b) => v -> v
- class ValueExtensible a v where
- type ValueExtensionArg a b
- extendByValue :: forall t -> t ~ a => forall b. ValueExtensionArg t b => b -> v -> v
- type DNSIO = ExceptT DNSError IO
- runDNSIO :: DNSIO a -> IO (Either DNSError a)
- liftDNS :: IO (Either DNSError a) -> DNSIO a
- module Net.DNSBase.Domain
- module Net.DNSBase.EDNS
- module Net.DNSBase.EDNS.OptNum
- module Net.DNSBase.EDNS.Option
- module Net.DNSBase.EDNS.Option.ECS
- module Net.DNSBase.EDNS.Option.EDE
- module Net.DNSBase.EDNS.Option.NSID
- module Net.DNSBase.EDNS.Option.Opaque
- module Net.DNSBase.EDNS.Option.Secalgs
- module Net.DNSBase.Error
- module Net.DNSBase.Flags
- module Net.DNSBase.Lookup
- module Net.DNSBase.Message
- module Net.DNSBase.NonEmpty
- module Net.DNSBase.Opcode
- module Net.DNSBase.RCODE
- module Net.DNSBase.RData
- module Net.DNSBase.RData.A
- module Net.DNSBase.RData.CAA
- module Net.DNSBase.RData.CSYNC
- module Net.DNSBase.Bytes
- module Net.DNSBase.Present
- module Net.DNSBase.RData.Dnssec
- module Net.DNSBase.RData.NSEC
- module Net.DNSBase.RData.SOA
- module Net.DNSBase.RData.SRV
- module Net.DNSBase.RData.SVCB
- module Net.DNSBase.RData.TLSA
- module Net.DNSBase.RData.TXT
- module Net.DNSBase.RData.XNAME
- module Net.DNSBase.Resolver
- module Net.DNSBase.RR
- module Net.DNSBase.RRCLASS
- module Net.DNSBase.RRTYPE
- module Net.DNSBase.Secalgs
- module Net.DNSBase.Text
Resolver setup
Static resolver configuration
data ResolverConf Source #
User-supplied resolver configuration. Carries the caller's
choices: where nameservers come from, the per-attempt timeout
and retry budget, default QueryControls, and any
user-registered RR-type / EDNS option codecs. Built-in defaults
are not stored here — they are merged into the effective
configuration only when makeResolvSeed produces a ResolvSeed.
defaultResolvConf :: ResolverConf Source #
Default resolver configuration, with nameserver list from
/etc/resolv.conf and no user-registered codec extensions.
data NameserverConf Source #
Configuration file name, or explicit list of addresses/hostnames.
Constructors
| SourceFile FilePath | |
| HostList (NonEmpty NameserverSpec) |
data NameserverSpec Source #
Nameserver address string or hostname, with optional port.
Constructors
| NameserverSpec | |
Fields | |
Resolver seeds
data ResolvSeed Source #
Resolved, immutable resolver state built by makeResolvSeed
from a ResolverConf. Combines the user's choices with the
library's built-in defaults: resolved nameserver addresses,
and the effective RR-type and EDNS-option codec maps with
user-registered code points overriding the library defaults
(except at a small set of protected code points, where
attempted user overrides are silently ignored).
A ResolvSeed is safe to share across threads; each query-issuing
thread should call withResolver on the same seed to obtain its
own per-thread Resolver handle.
makeResolvSeed :: ResolverConf -> IO (Either DNSError ResolvSeed) Source #
Build a ResolvSeed from a ResolverConf. The seed is
immutable and safely shared across threads; each thread then
calls withResolver to obtain its own Resolver.
The configured nameservers are resolved to socket addresses,
and the user's codec registrations (from registerRRtype,
extendRRwithType and registerEdnsOption) are combined with the
library's built-in codec set. At each RR-type or EDNS option
code point, the user-registered codec takes precedence over the
library default — except at a small set of protected code
points (e.g. the SVCB mandatory key), where any attempted
user override is silently ignored.
Returns if the configured nameservers cannot be
resolved or the configuration file cannot be parsed.Left err
Example:
>>>seed <- makeResolvSeed defaultResolvConf >>= either throwIO pure
Derived resolver objects
Internal DNS Resolver handle, obtained via withResolver.
Must not be used concurrently in multiple threads.
withResolver :: ResolvSeed -> (Resolver -> IO a) -> IO a Source #
Provide a Resolver to the supplied action. Concurrent use of a
single Resolver is not supported: the handle carries internal
mutable state and the library makes no soundness guarantees if it
is shared across threads. Programs that issue queries from
multiple threads must call withResolver once per worker thread
(typically inside forkIO) to obtain a separate handle. The
ResolvSeed itself is immutable and is the right object to share
across threads.
The action runs in plain IO; DNS-protocol errors from individual
lookups appear in the return shape of each
lookup function inside the action. This function does not itself
produce or propagate Either DNSError aDNSErrors.
Queries
extractAnswers :: DNSMessage -> IO (Either DNSError [RR]) Source #
Given a DNSMessage return answer RRs that match its question,
possibly after chasing CNAME aliases within the answer
section of the message.
lookupRaw :: Resolver -> Domain -> RRCLASS -> RRTYPE -> IO (Either DNSError DNSMessage) Source #
Perform a raw lookup returning the full DNSMessage or a
DNSError. See lookupRawCtl for the variant that takes
per-call query controls.
lookupRawCtl :: Resolver -> QueryControls -> Domain -> RRCLASS -> RRTYPE -> IO (Either DNSError DNSMessage) Source #
Perform a raw lookup with per-call QueryControls overrides,
returning the full DNSMessage or a DNSError. The supplied
controls are merged into the resolver's ambient query controls:
only the flag and EDNS bits specified in the controls affect the
outgoing query, the rest are inherited from the resolver
configuration. Use lookupAnswers (or the per-RRtype Lookup
functions) when you want only the answer RRs for the requested
name and type, rather than the entire response DNSMessage.
lookupAnswers :: Resolver -> QueryControls -> RRCLASS -> RRTYPE -> Domain -> IO (Either DNSError [RR]) Source #
Perform the requested query and return the answer RRs from the
response, or a DNSError carrying the RCODE for error responses.
The QueryControls argument carries per-call tweaks; it is
merged onto the resolver's ambient query controls, so callers only
need to specify the flag and EDNS bits they want to change, the
rest are inherited from the resolver configuration.
Note that NXDOMAIN is not a lookup error. An empty list of
RRs is returned for both NODATA and NXDOMAIN.
If the nameserver's response does not include any RRs matching
query name and type, but does include a CNAME record for the
requested name, the response is (recursively) rescanned for
records matching that name and type instead. Note, no
additional queries are issued if the final CNAME found does
not lead to any record of the desired record type.
The returned RRs may include covering DNSSEC signatures when the
DOflag is set as part of the QueryControls, and
the response was signed.
The presence of RRSIG records does not however imply that the
response was validated by the resolver. For that one would
typically use a trusted DNSSEC-validating local (loopback)
resolver, to which the network path is immune to potential
active attacks, and inspect the ADflag in
the response message.
The full response DNSMessage can be obtained via lookupRawCtl.
lookupAAAA :: Lookup IPv6 Source #
IPv6 addresses of query domain.
lookupCNAME :: Lookup Domain Source #
CNAMEs of query domain (should be at most one).
lookupTXT :: Lookup (NonEmpty ShortByteString) Source #
TXT RData of query domain. Applications typically concatenate each list
of character strings into a single combined value.
lookupTLSA :: Lookup T_tlsa Source #
TLSA RData of query domain.
lookupHTTPS :: Lookup T_https Source #
HTTPS RData of query domain.
Domain names
This type holds the wire form of fully-qualified DNS domain names encoded as A-labels.
The encoding of valid domain names to presentation form (the
Presentable instance) performs any required escaping of
special characters to ensure lossless round-trip encoding and
decoding of valid DNS names, and compatibility with the
standard zone file format. Valid names are not limited to the
letter-digit-hyphen (LDH) syntax of hostnames, all 8-bit
characters are allowed in DNS names, subject to the 63-byte
limit on wire form label length and 255-byte limit on the
wire form domain name (including the terminal empty label).
Equality and comparison are based on the wire-form and are
case-sensitive. The Host newtype implements case-insensitive
equality and comparison over the same wire-form bytes. The
toHost and fromHost functions implement coercions between
the two types.
Bundled Patterns
| pattern RootDomain :: Domain | The root |
Instances
| Presentable Domain Source # | Conversion to presentation form via a bytestring |
Defined in Net.DNSBase.Internal.Domain Methods present :: Domain -> Builder -> Builder Source # presentLazy :: Domain -> ByteString -> ByteString Source # | |
| Show Domain Source # | Shows the presentation form string, adding double quotes and additional
string escapes as needed. To get the raw string, use |
| Eq Domain Source # | |
| Ord Domain Source # | |
| Lift Domain Source # | |
Arguments
| :: forall e (m :: Type -> Type). (Show e, MonadFail m, Quote m) | |
| => (Text -> Either e ShortByteString) | Parser |
| -> String | Input literal (source code shape) |
| -> Code m Domain |
Template-Haskell typed splice for a compile-time Domain
literal. The caller supplies a parser of type
; Text -> Either e ShortByteStringdnLit packs the
source String literal as Text, runs the parser at compile
time, additionally checks the bytes via wireToDomain, and
embeds the resulting Domain as a constant. An invalid literal
(parser failure or wire-shape failure) becomes a compile-time
error.
The dnsbase library deliberately does not bundle a domain
parser; users compose a parser of their choice and pass it in.
The natural source of validating parsers is the idna2008
package, whose parsers already operate on Text.
Template-Haskell staging forbids referring to a same-module
top-level binding from inside the splice, so the parser must
either be defined in an imported module or bound by a let
inside the splice; for a single-call site the latter is the
more compact form:
import qualified Text.IDNA2008 as I
example :: Domain
example = $$(let parser = fmap I.wireBytesShort . I.mkDomain
in dnLit parser "www.example.org")mkDomain runs strict IDNA2008 with default label forms and
no mappings, returning just the validated idna2008 library's
Domain object. The I.wireBytesShort function extracts the
wire form bytes needed by dnLit.
For looser policies (mappings, emoji domain tolerance, etc.) use
parseDomainOpt with an explicit LabelFormSet and IDNAOpts,
and discard the LabelInfo half of its result.
Hoisting the parser into a separate module avoids retyping the composition at every literal:
-- in MyDomainParsers.hs strictParser :: Text -> Either I.IdnaError ShortByteString strictParser = fmap I.wireBytesShort . I.mkDomain -- in any module that imports MyDomainParsers example :: Domain example = $$(dnLit strictParser "www.example.org")
The source literal is converted to Text before the parser is
invoked; literals whose UTF-8 byte length exceeds 1024 are
rejected as invalid without consulting the parser. The emitted
splice is a constant Domain value (the wire-form
ShortByteString is materialised once from its compile-time
Addr# literal on first evaluation); the splice itself runs no
runtime IDNA code, and the caller's binary carries no
idna2008 dependency unless the user imports it themselves.
decodePresentationDomain Source #
Arguments
| :: (Text -> Either e ShortByteString) | Parser |
| -> Text | Input to be parsed |
| -> Either (Maybe e) Domain |
Decode a domain in presentation form. The caller supplies the
parser; this entry point validates the parser's output as a
wire-form ShortByteString that wireToDomain accepts.
When the parser returns an error e, the return value is
Left (Just e). If a buggy parser produces an invalid wire
form, the return value is Left Nothing.
dnLit8 :: forall (m :: Type -> Type). (Quote m, MonadFail m) => String -> Code m Domain Source #
Template-Haskell splice for literal Domain names that are
validated and converted from presentation form to wire form
at compile-time. Example:
domain :: Domain domain = $$(dnLit8 "example.org")
This is the byte-level path: it accepts any 8-bit master-file
text but performs no IDN processing. For IDN-aware literals (RFC
5890+, Punycode A-label encoding) use dnLit with a parser from
the companion idna2008 package.
makeDomain8 :: ByteString -> Either Domain8Err Domain Source #
Construct a Domain object directly from a presentation form
ByteString.
The bytes are not treated as UTF-8 content, and IDNA processing does not
apply. Backslash-escape encoding aside, each 8-bit byte in the input is
copied verbatim into the wire-form domain. For Unicode IDN domain support,
see the parsers in the idna2008 package.
Example
>>>import qualified Data.ByteString.Char8 as BC>>>dn = makeDomain8 $ BC.pack "www.corp.acme.example">>>dnRight "www.corp.acme.example.">>>toLabels <$> dnRight ["www","corp","acme","example"]
makeDomain8Str :: String -> Either Domain8Err Domain Source #
Same as makeDomain8, but the input is a String, and
an error (Left) is also returned if any of the input
string's characters are outside the 8-bit range.
Note that UTF-8 encoding of names in the Latin-1 alphabet might
still produce surprising results. For parsing IDN domain names,
see the idna2008 package.
Example
>>>dn = makeDomain8Str "www.corp.acme.example">>>dnRight "www.corp.acme.example.">>>toLabels <$> dnRight ["www","corp","acme","example"]
shortBytes :: Domain -> ShortByteString Source #
The wire form of a domain name, including the zero-valued length byte of the terminal empty label.
wireToDomain :: ShortByteString -> Maybe Domain Source #
Validating import of a wire-form ShortByteString as a
Domain. Returns Just iff the bytes are a well-formed DNS
domain on the wire:
- total length in
1..255, - every label length byte in
1..63except the trailing zero-byte root label, - label boundaries align exactly with the buffer end -- i.e. the terminating empty label's NUL length-byte is the last byte, and there is no truncation or trailing garbage.
Suitable for receiving bytes the caller cannot prove well-formed (e.g. labels handed back by a foreign library or another package). Wire-form bytes that come straight from the decoder in Net.DNSBase.Decode.Domain are already validated and do not need to round-trip through this check.
Resource records, RData, and messages
DNS Resource Record RFC1035 3.2.1
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | / / / NAME / | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TTL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RDLENGTH | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| / RDATA / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
The TYPE field is implicit in the polymorphic rrData.
Instances
| Presentable RR Source # | |
Defined in Net.DNSBase.Internal.RR Methods present :: RR -> Builder -> Builder Source # presentLazy :: RR -> ByteString -> ByteString Source # | |
| Show RR Source # | |
| Eq RR Source # | |
An RRSet is uniquely idenfified by a name, type, class triple.
Constructors
| DnsTriple | |
Fields | |
Instances
| Presentable DnsTriple Source # | |
Defined in Net.DNSBase.Internal.Domain Methods present :: DnsTriple -> Builder -> Builder Source # presentLazy :: DnsTriple -> ByteString -> ByteString Source # | |
| Show DnsTriple Source # | |
| Eq DnsTriple Source # | |
Wrapper around any concrete KnownRData type.
Its presentation form includes both the type and the value, space-separated. The underlying concrete types present just their values.
Instances
| Presentable RData Source # | Presents the type and value, space-separated. |
Defined in Net.DNSBase.Internal.RData Methods present :: RData -> Builder -> Builder Source # presentLazy :: RData -> ByteString -> ByteString Source # | |
| Show RData Source # | |
| Eq RData Source # | |
| Ord RData Source # | Compare RData first by RRtype number, then by content. When two RRtype numbers match, but the data types nevertheless differ, order opaque type after non-opaque. In the unlikely case of two non-opaque types with the same RRtype, compare their opaque encodings (this could throw an error if one of the objects is not encodable, perhaps because encoding would be too long). |
fromRData :: KnownRData a => RData -> Maybe a Source #
Recover a typed RR payload from the existential RData wrapper.
Returns when the dynamic payload's type matches the
caller's expected type Just xa, and Nothing otherwise.
The target type is selected by the result-side pattern; once
there's a concrete constructor on the Just side, the
constraint is resolved without an explicit type
ascription. A typical use is a view-pattern dispatch that
handles two or more RR types at once:KnownRData a
evalIP :: (IP -> a) -> RData -> Maybe a evalIP f (fromRData -> Just (T_A ip)) = Just $! f (IPv4 ip) evalIP f (fromRData -> Just (T_AAAA ip)) = Just $! f (IPv6 ip) evalIP _ _ = Nothing
fromRData is the right tool when the value in hand is already
an RData. If you instead have an RR (or a list of them, as
returned by lookupAnswers), rrDataCast is the convenience
composition . And fromRData . rrDatamonoRData performs
the filter-and-cast over a Foldable container in one step.
DNS Resource Record type numbers. The Presentable instance
displays the standard presentation form of the type name for
known types, or else TYPEnnnnn for a generic type number
nnnnn.
Instances
| Presentable RRTYPE Source # | |
Defined in Net.DNSBase.Internal.RRTYPE Methods present :: RRTYPE -> Builder -> Builder Source # presentLazy :: RRTYPE -> ByteString -> ByteString Source # | |
| Bounded RRTYPE Source # | |
| Enum RRTYPE Source # | |
Defined in Net.DNSBase.Internal.RRTYPE | |
| Num RRTYPE Source # | |
| Read RRTYPE Source # | |
| Integral RRTYPE Source # | |
Defined in Net.DNSBase.Internal.RRTYPE | |
| Real RRTYPE Source # | |
Defined in Net.DNSBase.Internal.RRTYPE Methods toRational :: RRTYPE -> Rational # | |
| Show RRTYPE Source # | |
| Eq RRTYPE Source # | |
| Ord RRTYPE Source # | |
DNS query or resource record class.
Instances
| Presentable RRCLASS Source # | |
Defined in Net.DNSBase.Internal.RRCLASS Methods present :: RRCLASS -> Builder -> Builder Source # presentLazy :: RRCLASS -> ByteString -> ByteString Source # | |
| Bounded RRCLASS Source # | |
| Enum RRCLASS Source # | |
| Num RRCLASS Source # | |
| Read RRCLASS Source # | |
| Integral RRCLASS Source # | |
Defined in Net.DNSBase.Internal.RRCLASS | |
| Real RRCLASS Source # | |
Defined in Net.DNSBase.Internal.RRCLASS Methods toRational :: RRCLASS -> Rational # | |
| Show RRCLASS Source # | |
| Eq RRCLASS Source # | |
| Ord RRCLASS Source # | |
Defined in Net.DNSBase.Internal.RRCLASS | |
data DNSMessage Source #
DNS query or response header, here consisting of just the query ID and the flags, sans the record counts, which are implicit in the corresponding lists, RFC1035 4.1.1, updated by RFC2535.
The basic DNS header contains the following fields:
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ID | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | QDCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ANCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | NSCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ARCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
The basic 4-bit RCODE is augmented with 8 bits from the EDNS header,
forming a single extended 12-bit RCODE, with the basic RCODE as its
least-significant 4 bits. Similarly, the extended 32-bit DNSFlags are
a combination of the basic flags above with 16 more flag bits from the
EDNS header, with the basic flags in the low 16-bits (with the Opcode
and RCODE bits always cleared).
DNS message format for queries and replies, RFC1035 4.1
+---------------------+ | Header | +---------------------+ | Question | the question for the name server +---------------------+ | Answer | RRs answering the question +---------------------+ | Authority | RRs pointing toward an authority +---------------------+ | Additional | RRs holding additional information +---------------------+
Instances
| Show DNSMessage Source # | |
Defined in Net.DNSBase.Internal.Message Methods showsPrec :: Int -> DNSMessage -> ShowS # show :: DNSMessage -> String # showList :: [DNSMessage] -> ShowS # | |
| Eq DNSMessage Source # | |
Defined in Net.DNSBase.Internal.Message | |
DNS API errors.
Constructors
| BadConfiguration String | Resolver misconfiguration. |
| BadNameserver IOException | Nameserver name -> address lookup failure. |
| DecodeError DecodeContext String | Error while decoding from wire form. |
| EncodeError EncodeContext | Error while encoding to wire form. |
| InvalidDomain String | Invalid domain name presentation form. |
| NetworkError NetworkContext | Error in connection establishment, data transmission or a timeout. |
| ProtocolError ProtocolContext | Unexpected DNS message. |
| ResponseError RCODE | DNS message indicates a remote error condition. |
| UserError UserContext | Invalid request. |
Instances
| Exception DNSError Source # | |
Defined in Net.DNSBase.Internal.Error Methods toException :: DNSError -> SomeException # fromException :: SomeException -> Maybe DNSError # displayException :: DNSError -> String # backtraceDesired :: DNSError -> Bool # | |
| Show DNSError Source # | |
| Eq DNSError Source # | |
Common resource record types
The A resource record
(RFC 1035 section 3.4.1)
— a 32-bit IPv4 address transmitted as four bytes in network
order. The derived Ord is numeric IPv4 order, which agrees
with canonical RR-content ordering
(RFC 4034 section 6.2).
See T_aaaa for the IPv6-family parallel, and evalIP for a
helper that handles either uniformly.
Instances
| Presentable T_a Source # | |||||
Defined in Net.DNSBase.RData.A Methods present :: T_a -> Builder -> Builder Source # presentLazy :: T_a -> ByteString -> ByteString Source # | |||||
| KnownRData T_a Source # | |||||
Defined in Net.DNSBase.RData.A Associated Types
Methods rdataExtensionVal :: forall b -> b ~ T_a => RDataExtensionVal T_a Source # rdType :: forall b -> b ~ T_a => RRTYPE Source # rdTypePres :: forall b -> b ~ T_a => Builder -> Builder Source # rdDecode :: forall b -> b ~ T_a => RDataExtensionVal T_a -> Int -> SGet RData Source # | |||||
| Enum T_a Source # | |||||
| Show T_a Source # | |||||
| Eq T_a Source # | |||||
| Ord T_a Source # | |||||
| type RDataExtensionVal T_a Source # | |||||
Defined in Net.DNSBase.RData.A | |||||
The AAAA resource record
(RFC 3596 section 2.1)
— a 128-bit IPv6 address transmitted as sixteen bytes in network
order. The derived Ord is numeric IPv6 order, which agrees
with canonical RR-content ordering
(RFC 4034 section 6.2).
See T_a for the IPv4-family parallel, and evalIP for a
helper that handles either uniformly.
Instances
| Presentable T_aaaa Source # | |||||
Defined in Net.DNSBase.RData.A Methods present :: T_aaaa -> Builder -> Builder Source # presentLazy :: T_aaaa -> ByteString -> ByteString Source # | |||||
| KnownRData T_aaaa Source # | |||||
Defined in Net.DNSBase.RData.A Associated Types
Methods rdataExtensionVal :: forall b -> b ~ T_aaaa => RDataExtensionVal T_aaaa Source # rdType :: forall b -> b ~ T_aaaa => RRTYPE Source # rdTypePres :: forall b -> b ~ T_aaaa => Builder -> Builder Source # rdDecode :: forall b -> b ~ T_aaaa => RDataExtensionVal T_aaaa -> Int -> SGet RData Source # | |||||
| Show T_aaaa Source # | |||||
| Eq T_aaaa Source # | |||||
| Ord T_aaaa Source # | |||||
| type RDataExtensionVal T_aaaa Source # | |||||
Defined in Net.DNSBase.RData.A | |||||
The MX resource record
(RFC 1035 section 3.3.9)
— a mail exchanger for the owner name: a 16-bit preference
(lower is preferred) and a Domain naming the exchange host.
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / EXCHANGE / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
The exchange field is subject to wire-form name compression on
encode
(RFC 3597 section 4)
and canonicalises to lower case
(RFC 4034 section 6.2).
The Eq and Ord instances compare the exchange in canonical
wire form (via equalWireHost / compareWireHost), so Ord
is canonical.
A name that resolves to a CNAME should not be used in the exchange field (RFC 2181 section 10.3, RFC 5321 section 5.1).
Instances
| Presentable T_mx Source # | |||||
Defined in Net.DNSBase.RData.SRV Methods present :: T_mx -> Builder -> Builder Source # presentLazy :: T_mx -> ByteString -> ByteString Source # | |||||
| KnownRData T_mx Source # | |||||
Defined in Net.DNSBase.RData.SRV Associated Types
Methods rdataExtensionVal :: forall b -> b ~ T_mx => RDataExtensionVal T_mx Source # rdType :: forall b -> b ~ T_mx => RRTYPE Source # rdTypePres :: forall b -> b ~ T_mx => Builder -> Builder Source # rdDecode :: forall b -> b ~ T_mx => RDataExtensionVal T_mx -> Int -> SGet RData Source # | |||||
| Show T_mx Source # | |||||
| Eq T_mx Source # | Case-insensitive wire-form equality. | ||||
| Ord T_mx Source # | Case-insensitive wire-form order. | ||||
| type RDataExtensionVal T_mx Source # | |||||
Defined in Net.DNSBase.RData.SRV | |||||
The SRV resource record
(RFC 2782)
— names the location of a service: 16-bit priority, weight,
and port, plus a Domain naming the target host.
The target field is not subject to wire-form name compression
on encode
(RFC 3597 section 4)
but compression is tolerated on decode. It canonicalises to
lower case
(RFC 4034 section 6.2).
The Eq and Ord instances compare the target in canonical
wire form (via equalWireHost / compareWireHost), so Ord
is canonical.
Constructors
| T_SRV | |
Instances
| Presentable T_srv Source # | |||||
Defined in Net.DNSBase.RData.SRV Methods present :: T_srv -> Builder -> Builder Source # presentLazy :: T_srv -> ByteString -> ByteString Source # | |||||
| KnownRData T_srv Source # | |||||
Defined in Net.DNSBase.RData.SRV Associated Types
Methods rdataExtensionVal :: forall b -> b ~ T_srv => RDataExtensionVal T_srv Source # rdType :: forall b -> b ~ T_srv => RRTYPE Source # rdTypePres :: forall b -> b ~ T_srv => Builder -> Builder Source # rdDecode :: forall b -> b ~ T_srv => RDataExtensionVal T_srv -> Int -> SGet RData Source # | |||||
| Show T_srv Source # | |||||
| Eq T_srv Source # | Equality is not case-senstive on the target host name. | ||||
| Ord T_srv Source # | Order is not case-senstive on the target host name. | ||||
| type RDataExtensionVal T_srv Source # | |||||
Defined in Net.DNSBase.RData.SRV | |||||
The TXT resource record
(RFC 1035 section 3.3.14)
— a non-empty list of byte-strings, each at most 255 bytes long.
Most TXT-record conventions (SPF, DKIM, DMARC, ...) concatenate
the strings on read, but the wire format preserves the boundaries.
The constructor does not enforce the per-string 255-byte limit; encoding fails if any individual string exceeds it. Values decoded from wire form are always within the limit by construction.
The Ord instance compares the strings as DNS
character-strings (length-prefixed lexicographic), agreeing
with the canonical wire-form ordering of
RFC 4034 section 6.2.
Constructors
| T_TXT (NonEmpty ShortByteString) | One or more character-strings |
Instances
| Presentable T_txt Source # | |||||
Defined in Net.DNSBase.RData.TXT Methods present :: T_txt -> Builder -> Builder Source # presentLazy :: T_txt -> ByteString -> ByteString Source # | |||||
| KnownRData T_txt Source # | |||||
Defined in Net.DNSBase.RData.TXT Associated Types
Methods rdataExtensionVal :: forall b -> b ~ T_txt => RDataExtensionVal T_txt Source # rdType :: forall b -> b ~ T_txt => RRTYPE Source # rdTypePres :: forall b -> b ~ T_txt => Builder -> Builder Source # rdDecode :: forall b -> b ~ T_txt => RDataExtensionVal T_txt -> Int -> SGet RData Source # | |||||
| Show T_txt Source # | |||||
| Eq T_txt Source # | |||||
| Ord T_txt Source # | |||||
| type RDataExtensionVal T_txt Source # | |||||
Defined in Net.DNSBase.RData.TXT | |||||
pattern T_PTR :: Domain -> T_ptr Source #
Domain-name pointer, typically used for reverse mapping (RFC 1035 section 3.3.12).
Record pattern synonym viewing the shared X_svcb record as
an HTTPS service-binding record (RFC 9460). Fields:
httpsPriority, httpsTarget, httpsParamValues.
Query and EDNS controls
data QueryControls where Source #
Query controls consisting of an endomorphism over FlagOps to modify
DNS flag bits, and an EdnsControls structure to configure EDNS
behavior.
Constitutes a Monoid with left-biased mappend operation
Bundled Patterns
| pattern QctlFlags | Apply the requested DNS flag operation, setting or clearing the requested flag bits, or restoring defaults. |
Fields
| |
| pattern EdnsEnabled :: QueryControls | Enable EDNS for this query, overriding the resolver default if it had EDNS disabled. The OPT pseudo-RR is included in the outgoing query. |
| pattern EdnsDisabled :: QueryControls | Disable EDNS for this query. When EDNS is disabled, the OPT
pseudo-RR is omitted from the outgoing query and the other
EDNS-related tweaks ( |
| pattern EdnsUdpSize | Override the maximum UDP payload size the client advertises
to the server for this query. The value is clamped to the
|
Fields
| |
| pattern EdnsOptionCtl | Carry a per-call modification of the OPT pseudo-RR's EDNS
option list as an endomorphism
let noEcs = EdnsOptionCtl
$ optCtlAdd [ EdnsOption
$ O_ECS 0 0 (IPv4 (toIPv4 [0,0,0,0])) ]
in lookupAnswers rslv noEcs IN A $$(dnLit8 "example.org")
|
Fields
| |
Instances
| Monoid QueryControls Source # | |
Defined in Net.DNSBase.Resolver.Internal.Types Methods mempty :: QueryControls # mappend :: QueryControls -> QueryControls -> QueryControls # mconcat :: [QueryControls] -> QueryControls # | |
| Semigroup QueryControls Source # | |
Defined in Net.DNSBase.Resolver.Internal.Types Methods (<>) :: QueryControls -> QueryControls -> QueryControls # sconcat :: NonEmpty QueryControls -> QueryControls # stimes :: Integral b => b -> QueryControls -> QueryControls # | |
| Show QueryControls Source # | |
Defined in Net.DNSBase.Resolver.Internal.Types Methods showsPrec :: Int -> QueryControls -> ShowS # show :: QueryControls -> String # showList :: [QueryControls] -> ShowS # | |
pattern RDflag :: DNSFlags Source #
RD (Recursion Desired) - This bit may be set in a query and is copied into the response. If RD is set, it directs the name server to pursue the query recursively. Authoritative servers may refuse recursive queries, and, conversely, iterative resolvers may refuse non-recursive queries.
pattern ADflag :: DNSFlags Source #
AD (Authentic Data) bit - RFC4035, Section 3.2.3. See also RFC6840, Section 5.8
Extending the library
class (Typeable a, Eq a, Ord a, Show a, Presentable a) => KnownRData a Source #
Abstract DNS Resource Record (type-specific) data.
The decoding, encoding and presentation functions are responsible for just
the value, presentation of the associated RR type defaults to the built-in
names, for novel types override rdTypePres.
The Show instance is typically derived, and will output the type
constructor (its output strives to produce syntactically valid Haskell
values), in contrast with Presentable which produces RFC-standard
presentation forms.
Instances
registerRRtype :: forall a -> KnownRData a => ResolverConf -> ResolverConf Source #
Register a decoder for an RR-type.
If the RR's data type is itself extensible, you can
use extendRRwithType or extendRRwithValue to
apply additional extensions on top.
The registration takes precedence over the library's built-in codec at the same RR-type code, except at protected code points (e.g. RR-type 0 and 65535, or the OPT pseudo-RR), where the registration is silently ignored.
extendRRwithType :: forall t -> (KnownRData t, TypeExtensible t (RDataExtensionVal t)) => forall b -> TypeExtensionArg t b => ResolverConf -> ResolverConf Source #
Extend the registered codec of a type-extensible RR type t
with an additional typed extension b. If t is not yet
known it is automatically registered, in either case extendByType
is then applied to the existing decoder state to fold in b.
This is how one adds an extra SvcParam-key decoder for SVCB and/or HTTPS records.
conf
& extendRRwithType T_svcb MyParamType
& extendRRwithType T_https MyParamTypeextendRRwithValue :: forall t -> (KnownRData t, ValueExtensible t (RDataExtensionVal t)) => forall b. ValueExtensionArg t b => b -> ResolverConf -> ResolverConf Source #
Extend the registered codec for RR type t with a
caller-supplied value v, whose type satisfies t's
ValueExtensionArg constraint. Parallel to
extendRRwithType, but for instances whose extension table
is keyed by runtime data rather than user-supplied types.
class (Typeable a, Eq a, Show a, Presentable a) => KnownEdnsOption a Source #
EDNS option class with conversion to/from opaque EdnsOption form.
Instances
| KnownEdnsOption O_ecs Source # | |||||
Defined in Net.DNSBase.EDNS.Option.ECS Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_ecs => OptionExtensionVal O_ecs Source # optNum :: forall b -> b ~ O_ecs => OptNum Source # optPres :: forall b -> b ~ O_ecs => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_ecs -> SPut s r Source # optDecode :: forall b -> b ~ O_ecs => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| KnownEdnsOption O_ede Source # | |||||
Defined in Net.DNSBase.EDNS.Option.EDE Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_ede => OptionExtensionVal O_ede Source # optNum :: forall b -> b ~ O_ede => OptNum Source # optPres :: forall b -> b ~ O_ede => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_ede -> SPut s r Source # optDecode :: forall b -> b ~ O_ede => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| KnownEdnsOption O_nsid Source # | |||||
Defined in Net.DNSBase.EDNS.Option.NSID Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_nsid => OptionExtensionVal O_nsid Source # optNum :: forall b -> b ~ O_nsid => OptNum Source # optPres :: forall b -> b ~ O_nsid => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_nsid -> SPut s r Source # optDecode :: forall b -> b ~ O_nsid => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| KnownEdnsOption O_dau Source # | |||||
Defined in Net.DNSBase.EDNS.Option.Secalgs Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_dau => OptionExtensionVal O_dau Source # optNum :: forall b -> b ~ O_dau => OptNum Source # optPres :: forall b -> b ~ O_dau => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_dau -> SPut s r Source # optDecode :: forall b -> b ~ O_dau => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| KnownEdnsOption O_dhu Source # | |||||
Defined in Net.DNSBase.EDNS.Option.Secalgs Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_dhu => OptionExtensionVal O_dhu Source # optNum :: forall b -> b ~ O_dhu => OptNum Source # optPres :: forall b -> b ~ O_dhu => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_dhu -> SPut s r Source # optDecode :: forall b -> b ~ O_dhu => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| KnownEdnsOption O_n3u Source # | |||||
Defined in Net.DNSBase.EDNS.Option.Secalgs Associated Types
Methods optionExtensionVal :: forall b -> b ~ O_n3u => OptionExtensionVal O_n3u Source # optNum :: forall b -> b ~ O_n3u => OptNum Source # optPres :: forall b -> b ~ O_n3u => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => O_n3u -> SPut s r Source # optDecode :: forall b -> b ~ O_n3u => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
| Nat16 n => KnownEdnsOption (OpaqueOption n) Source # | |||||
Defined in Net.DNSBase.EDNS.Internal.Option.Opaque Associated Types
Methods optionExtensionVal :: forall b -> b ~ OpaqueOption n => OptionExtensionVal (OpaqueOption n) Source # optNum :: forall b -> b ~ OpaqueOption n => OptNum Source # optPres :: forall b -> b ~ OpaqueOption n => Builder -> Builder Source # optEncode :: forall s r. (Typeable r, Eq r, Show r) => OpaqueOption n -> SPut s r Source # optDecode :: forall b -> b ~ OpaqueOption n => OptionExtensionVal b -> Int -> SGet EdnsOption Source # | |||||
registerEdnsOption :: forall a -> KnownEdnsOption a => ResolverConf -> ResolverConf Source #
Register an EDNS option decoder.
If the EDNS option's data type is itself extensible, you can
use extendEdnsOptionWithType or extendEdnsOptionWithValue to
apply additional extensions on top.
The registration takes precedence over the library's built-in
decoder at the same option code (if any) after the merge step
in makeResolvSeed.
extendEdnsOptionWithType :: forall t -> (KnownEdnsOption t, TypeExtensible t (OptionExtensionVal t)) => forall b -> TypeExtensionArg t b => ResolverConf -> ResolverConf Source #
Extend the registered decoder for a type-extensible EDNS option
type t with an additional typed extension b. If t is not
yet present in the resolver configuration, it is first registered,
in either case extendByType is then applied fold in b.
This is the EDNS-option-side parallel to extendRRwithType.
extendEdnsOptionWithValue :: forall t -> (KnownEdnsOption t, ValueExtensible t (OptionExtensionVal t)) => forall b. ValueExtensionArg t b => b -> ResolverConf -> ResolverConf Source #
Extend the registered codec for EDNS option type t with
a caller-supplied value v, whose type satisfies t's
ValueExtensionArg constraint. The EDNS-option-side
parallel to extendRRwithValue. This is the canonical way
to add an EDE info-code → friendly-name mapping:
conf
& extendEdnsOptionWithValue O_ede (33, "Frobnicated")
& extendEdnsOptionWithValue O_ede (34, "Bogosity")class (Typeable a, Eq a, Ord a, Show a, Presentable a) => KnownSVCParamValue a Source #
The class of types representing the value side of a service
parameter inside an SVCB or HTTPS record. Each instance
corresponds to a specific SVCParamKey; the encodeSPV and
decodeSPV methods handle only the value bytes. The
surrounding (key, length) frame is owned by the SVCB-record
encoder: encodeSPV writes just the payload, and the framework
wraps the result in the 2-byte length prefix.
For value-less parameters this means encodeSPV is just
pure ().
The Presentable instance builds the RFC 9460 zone-file
presentation form: the key name followed (where the value is
non-empty) by = and the value. The Show instance is
typically derived and aims to produce syntactically valid
Haskell.
Instances
| KnownSVCParamValue SPV_alpn Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV | |
| KnownSVCParamValue SPV_docpath Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_docpath => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_docpath => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_docpath -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_docpath => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_dohpath Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_dohpath => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_dohpath => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_dohpath -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_dohpath => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_ech Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV | |
| KnownSVCParamValue SPV_ipv4hint Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_ipv4hint => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_ipv4hint => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_ipv4hint -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_ipv4hint => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_ipv6hint Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_ipv6hint => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_ipv6hint => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_ipv6hint -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_ipv6hint => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_mandatory Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_mandatory => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_mandatory => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_mandatory -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_mandatory => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_ndalpn Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_ndalpn => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_ndalpn => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_ndalpn -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_ndalpn => Int -> SGet SVCParamValue Source # | |
| KnownSVCParamValue SPV_port Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV | |
| KnownSVCParamValue SPV_pvd Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV | |
| KnownSVCParamValue SPV_tlsgroups Source # | |
Defined in Net.DNSBase.RData.SVCB.SPV Methods spvKey :: forall b -> b ~ SPV_tlsgroups => SVCParamKey Source # spvKeyPres :: forall b -> b ~ SPV_tlsgroups => Builder -> Builder Source # encodeSPV :: ErrorContext r => SPV_tlsgroups -> SPut s r Source # decodeSPV :: forall b -> b ~ SPV_tlsgroups => Int -> SGet SVCParamValue Source # | |
| Nat16 n => KnownSVCParamValue (OpaqueSPV n) Source # | |
Defined in Net.DNSBase.RData.SVCB.SVCParamValue | |
class TypeExtensible a v where Source #
RR-data or EDNS-option types whose codec admits a type-driven extension. See Adding a custom RR type for an example of this mechanism in use, and Writing a type-driven extensible codec for the steps to implement a type-driven extensible codec of your own.
Associated Types
type TypeExtensionArg a b Source #
Constraint a caller's extension type b must satisfy.
Methods
extendByType :: forall t b -> (t ~ a, TypeExtensionArg t b) => v -> v Source #
Fold a caller's extension type b into the existing
codec context value of type v.
class ValueExtensible a v where Source #
RR-data or EDNS-option types whose codec admits a value-driven extension. See Adding a valud-driven extension for an example of this mechanism in use, and Writing a value-driven extensible codec for the steps to implement a value-driven extensible codec of your own.
Associated Types
type ValueExtensionArg a b Source #
Constraint a caller's extension value type b must
satisfy.
Methods
extendByValue :: forall t -> t ~ a => forall b. ValueExtensionArg t b => b -> v -> v Source #
Fold a caller-supplied value of type b into the
existing codec context value of type v.
Instances
| ValueExtensible O_ede (IntMap ShortByteString) Source # | |||||
Defined in Net.DNSBase.EDNS.Option.EDE Associated Types
Methods extendByValue :: forall t -> t ~ O_ede => forall b. ValueExtensionArg t b => b -> IntMap ShortByteString -> IntMap ShortByteString Source # | |||||
Chained-composition opt-in
type DNSIO = ExceptT DNSError IO Source #
An opt-in monad for chaining multiple DNS operations with
short-circuit error handling. The primary public API uses plain
; IO (Either DNSError a)DNSIO is a thin wrapper around
for users who prefer transformer-style
composition. Convert between the two forms with ExceptT DNSError IOrunDNSIO and
liftDNS.
Reference: all re-exported modules
module Net.DNSBase.Domain
module Net.DNSBase.EDNS
module Net.DNSBase.EDNS.OptNum
module Net.DNSBase.EDNS.Option
module Net.DNSBase.EDNS.Option.ECS
module Net.DNSBase.EDNS.Option.EDE
module Net.DNSBase.EDNS.Option.NSID
module Net.DNSBase.Error
module Net.DNSBase.Flags
module Net.DNSBase.Lookup
module Net.DNSBase.Message
module Net.DNSBase.NonEmpty
module Net.DNSBase.Opcode
module Net.DNSBase.RCODE
module Net.DNSBase.RData
module Net.DNSBase.RData.A
module Net.DNSBase.RData.CAA
module Net.DNSBase.RData.CSYNC
module Net.DNSBase.Bytes
module Net.DNSBase.Present
module Net.DNSBase.RData.Dnssec
module Net.DNSBase.RData.NSEC
module Net.DNSBase.RData.SOA
module Net.DNSBase.RData.SRV
module Net.DNSBase.RData.SVCB
module Net.DNSBase.RData.TLSA
module Net.DNSBase.RData.TXT
module Net.DNSBase.RData.XNAME
module Net.DNSBase.Resolver
module Net.DNSBase.RR
module Net.DNSBase.RRCLASS
module Net.DNSBase.RRTYPE
module Net.DNSBase.Secalgs
module Net.DNSBase.Text