Caddy 2 uses a new set of interfaces for its DNS provider APIs. While there is a shim to use all the existing old ones for now, the new APIs offer better performance, leaner builds, and more capabilities. We want all providers to be ported over to the new APIs as soon as possible.
Since I do not have accounts with all DNS providers in the world, it’s up to the community to migrate to the new APIs and to maintain their implementations. This post will show you how!
For what it’s worth, I was able to implement the Cloudflare package using only the Go standard library in just about a day. It shouldn’t take you too long!
libdns
The new interfaces/APIs are called libdns
. You should at least skim over its README.
Writing a new dns.providers module
Writing a new DNS provider module for Caddy has two main steps:
-
Create a libdns package that implements the DNS provider using the
libdns
APIs. There are instructions and tips in that repository’s wiki. This is the code that actually manipulates DNS records with your DNS provider, but this code does not know about (import) Caddy or any ACME libraries whatsoever. Here is a libdns template repository you can start with. -
Create a caddy-dns package that turns your libdns package into a Caddy module. This consists of a very simple Go module that has 20 lines (but for full support including Caddyfile, it’s a bit longer). Here is a caddy-dns template repository you can start with.
Once you confirm it works with Caddy, let’s get it added to the caddy-dns organization so others can use it.
The libdns APIs are ideal for Caddy because they result in better performance, significantly less bloat, more capacity for growth, and more flexibility (they can be used for more than just solving ACME challenges; for example, a dynamic DNS app can use them to update A/AAAA records).
Thanks for contributing to the project!