[ANN] dnsbase 1.0: a flexible successor to the "dns" library

If you write DNS-related code in Haskell — or have been thinking about it — there’s a new library on Hackage that may be worth a look: dnsbase 1.0.2.0.

dnsbase is a DNS stub-resolver library. Its IO layer is derived from Kazu Yamamoto’s dns package, and the basic lookup interface — lookupA, lookupMX, lookupTXT, … — is deliberately similar, so migration is straightforward for anyone already familiar with dns. What dnsbase layers on top sits in the resource-record data model and the configuration story.

Every RR type’s payload is modeled with its own Haskell type. SVCB and HTTPS service-binding records (RFC 9460) are first-class, with up-to-date SvcParam coverage. EDNS option support includes Extended DNS Errors with a user-extensible info-code name registry. Coverage of both widely-deployed and historical RR types is comprehensive — only the most marginal obsolete or experimental types remain unimplemented.

Applications can extend the library at runtime with new RR types, EDNS options, or SVCB/HTTPS SvcParam values without forking the library code. Extensions are registered by constructing a pure resolver configuration value, not via side-effects on mutable global state, and application-supplied types take precedence over the library’s built-in implementation at the same codepoint. The Net.DNSBase.Extensible module has worked examples, and three runnable demos in the demos/ directory cover adding a custom RR type, an EDNS option, and an SVCB parameter value.

The library does not throw exceptions; lookups return IO (Either DNSError a) for various values of a. Exceptions are just an either throwIO pure away, if you prefer to throw and catch exceptions.

The library has been deployed for 6+ years as part of a DANE/DNSSEC survey (used dns for ~4 years before that) — this makes ~108 million queries per day in ~3.5-hours, along with SMTP STARTTLS probes and database updates. Porting that production engine to 1.0 was the final validation step before this release.

dnsbase requires GHC 9.10 or 9.12. The API makes essential use of RequiredTypeArguments and a handful of other recent extensions, so the lower bound isn’t easily relaxed; if you’re on an older compiler, please bookmark this for when you next upgrade.

The library meshes well with the companion idna2008 package, also just released, making it possible to correctly parse IDN domain names.

Feedback, bug reports, and contributions are welcome at github.com/dnsbase/dnsbase. If you’ve ever wished for stronger types on the RData side, or wanted to handle an SVCB parameter your DNS library didn’t yet support, dnsbase is built for exactly that.

— Viktor