dnsbase: Stub DNS resolver with a typed RData model and value-based extension API

[ bsd3, dns, library, network ] [ Propose Tags ] [ Report a vulnerability ]
This version is deprecated.

A DNS stub resolver library for Haskell. The IO layer is derived from Kazu Yamamoto's dns package; what dnsbase adds is a rich set of RRtypes and a runtime-extensible RRtype data model with a simple configuration interface. . Every RR type's payload is modeled as a dedicated Haskell type — these include, for example, the recent SVCB and HTTPS service-binding records, with extensible up-to-date SvcParam coverage. EDNS option support includes Extended DNS Errors (EDE) whose info-code name table is user-extensible. Coverage of both widely used and historical DNS RR types is comprehensive — only the most marginal obsolete or experimental types remain unimplemented. . Applications can extend the library with any missing RRTYPEs, EDNS(0) options, SVCB and HTTPS SvcParam 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 the Net.DNSBase.Extensible module for detailed examples . The library has been deployed as part of a DANE/DNSSEC survey for many years, and performs ~108 million queries each day, over approximately 3.5 hours (while also saving results to a database and performing some SMTP STARTTLS probes). Domain-name parsing supports 8-bit RFC 1035 names directly and also supports pluggable Text-based parsers via external libraries, for example from the companion idna2008 package. .


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.0.1.0, 1.0.2.0 (info)
Change log CHANGELOG.md
Dependencies base (>=4.20 && <5), base16 (>=1.0 && <1.1), base32 (>=0.3 && <0.5), base64 (>=1.0 && <1.1), bytestring (>=0.10.8 && <0.13), containers (>=0.6 && <0.9), crypton (>=0.30 && <1.2), deepseq (>=1.5 && <1.6), hashtables (>=1.2 && <1.6), hourglass (>=0.2.12 && <0.3), iproute (>=1.7.9 && <1.8), monad-ste (>=0.1 && <0.2), mtl (>=2.2 && <2.4), network (>=3.1 && <3.3), primitive (>=0.8 && <0.10), template-haskell (>=2.22 && <2.25), text (>=2.0 && <2.2), time (>=1.11 && <1.16), transformers (>=0.5 && <2.7), unordered-containers (>=0.2 && <0.3) [details]
Tested with ghc ==9.10.3, ghc ==9.12.3
License BSD-3-Clause[multiple license files]
Copyright 2018-2026 Viktor Dukhovni
Author Viktor Dukhovni
Maintainer ietf-dane@dukhovni.org
Uploaded by ietfdane at 2026-06-07T16:50:24Z
Category Network
Home page https://github.com/dnsbase/dnsbase
Bug tracker https://github.com/dnsbase/dnsbase/issues
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2026-06-07 [all 2 reports]

Readme for dnsbase-1.0.0.0

[back to package description]

Base DNS library with extensible core types

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.

Applications can extend the library with any missing RRtypes, EDNS(0) options, or SVCB / HTTPS SvcParam 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.

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.

Basic MX lookup example

The example below prints the MX records of ietf.org, if any, or an error message if the answer can't be obtained.

The compile-time literal splice used here is dnLit8, the octet-level form that accepts any RFC 1035 master-file string (the input is treated as raw bytes, with \DDD and \C escapes). For IDN-aware literals — strict IDNA2008 validation, U-label encoding to A-labels, optional cross-label Bidi checks — use dnLit from Net.DNSBase.Domain with a parser from the companion idna2008 package; see the dnLit haddock for the composition idiom.

{-# LANGUAGE
    BlockArguments
  , LambdaCase
  , RecordWildCards
  , TemplateHaskell
  #-}
import Control.Exception (throwIO)
import Net.DNSBase
import System.IO (stdout)

main :: IO ()
main = makeResolvSeed defaultResolvConf >>= \ case
    Right seed -> withResolver seed \ r ->
        lookupMX r $$(dnLit8 "ietf.org") >>= \ case
            Right mxs -> hPutBuilder stdout $ foldr presentLn mempty mxs
            Left errs -> throwIO errs
    Left errs -> throwIO errs

Custom extensions

The demos/ directory contains worked examples for each of the three extension targets:

  • demoextrr.hs — adding a custom RR type, by shadowing the standard A record with a raw-Word32 representation that presents each address as eight hex nibbles under a made-up name HEXA. Shows the KnownRData instance shape and registration via registerRRtype.
  • demoextopt.hs — adding an EDNS(0) option (the EDNS cookie, RFC 7873), queried directly against ns1.isc.org to elicit a server cookie. Shows the KnownEdnsOption instance shape, registration via registerEdnsOption, and per-call option injection via optCtlAdd.
  • demoextspv.hs — adding (here, shadowing) an HTTPS / SVCB service parameter, by re-implementing the ipv4hint key (codepoint 4) with a raw-Word32-list representation and a hex presentation form under a made-up name IPV4HEX. Shows the KnownSVCParamValue instance shape and the registration via extendRRwithType applied to both T_svcb and T_https (SVCB-shaped RRs share the SvcParam codec map).

Each demo is a self-contained program; copy one into a project and adjust the queries to taste.