# Handlers

atomdns links handlers together, each handler performs a single task. Together these make up the functionality
of the DNS server. This kind of architecture is called server [middleware](https://en.wikipedia.org/wiki/Middleware).
atomdns' configuration mostly exists out of picking what _handlers_ you want to run. The order of the handlers
in the configuration file determines that order in which they are called in the server.

Each [handler](https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers) has its own documentation
in their README.md.

There are several types of handlers:

- handlers that return a response, i.e. {{< dbhost >}} in one.
- handlers that observe, and hand the DNS message over to the next handler, {{< metrics >}} for instance.
- handlers that change the in-transit message and call the next handler. Currently these are not implemented.
- hanlders that add data to the context, {{< geoip >}} adds geographical data to it. This allows handlers
  up-to-chain to make use of that data, {{< acl >}} uses this data.

How atomdns handles DNS queries [is detailed in this
README.md](https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/README.md).

{{< cards >}}

{{% card title="global" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/global/README.md" %}}
_global_ - hold global server properties
{{% /card %}}

{{% card title="acl" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/acl/README.md" %}}
_acl_ - enforces access control policies
{{% /card %}}

{{% card title="any" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/any/README.md" %}}
_any_ - give a minimal response to ANY queries
{{% /card %}}

{{% card title="as112" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/as112/README.md" %}}
_as112_ - an AS112 black hole server
{{% /card %}}

{{% card title="chaos" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/chaos/README.md" %}}
_chaos_ - respond to TXT queries in the CH class
{{% /card %}}

{{% card title="cookie" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/cookie/README.md" %}}
_cookie_ - adds an DNS cookie of this server to each reply
{{% /card %}}

{{% card title="dbfile" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/dbfile/README.md" %}}
_dbfile_ - serve zone data from an RFC 1035-style file
{{% /card %}}

{{% card title="dbhost" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/dbhost/README.md" %}}
_dbhosts_ - serve data from /etc/hosts
{{% /card %}}

{{% card title="dbsqlite" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/dbsqlite/README.md" %}}
_dbsqilte_ - serve zone data from a SQLite database
{{% /card %}}

{{% card title="drunk" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/drunk/README.md" %}}
_drunk_ - test client behavior
{{% /card %}}

{{% card title="ecs" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/ecs/README.md" %}}
_ecs_ - add client subnet address
{{% /card %}}

{{% card title="empty" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/empty/README.md" %}}
_empty_ - consume setup tokens
{{% /card %}}

{{% card title="geoip" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/geoip/README.md" %}}
_geoip_ - add geographical location data
{{% /card %}}

{{% card title="id" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/id/README.md" %}}
_id_ - add request ID to the context
{{% /card %}}

{{% card title="kill" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/kill/README.md" %}}
_kill_ - stop the server after a duration
{{% /card %}}

{{% card title="log" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/log/README.md" %}}
_log_ - log queries
{{% /card %}}

{{% card title="metrics" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/metrics/README.md" %}}
_metrics_ - enable [prometheus](https://prometheus.io/) metrics
{{% /card %}}

{{% card title="nsid" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/nsid/README.md" %}}
_nsid_ - adds an identifier of this server to each reply
{{% /card %}}

{{% card title="refuse" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/refuse/README.md" %}}
_refuse_ - refuse queries
{{% /card %}}

{{% card title="root" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/root/README.md" %}}
_root_ - override the global root
{{% /card %}}

{{% card title="sign" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/sign/README.md" %}}
_sign_ - add DNSSEC records to zone files
{{% /card %}}

{{% card title="template" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/template/README.md" %}}
_template_ - use Go templates to reply
{{% /card %}}

{{% card title="tsig" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/tsig/README.md" %}}
_tsig_ - validate incoming TSIG signed messages
{{% /card %}}

{{% card title="unpack" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/unpack/README.md" %}}
_unpack_ - unpack the initial query
{{% /card %}}

{{% card title="url" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/url/README.md" %}}
_url_ - serve zone data from an URL
{{% /card %}}

{{% card title="whoami" href="https://codeberg.org/miekg/dns/src/branch/main/cmd/atomdns/handlers/whoami/README.md" %}}
_whoami_ - return your resolver's local IP address, port and transport
{{% /card %}}

{{< /cards >}}
