Kantoor.DnsRecords (Kantoor v1.0.0)

The DNS records an operator publishes for one mail domain so that mail, calendar and contact clients find Kantoor from an email address.

This module is pure: it derives the exact record set from the live configuration and touches no socket. Kantoor.DnsRecords.Checker resolves the records, the admin page and the provisioning API show them. Every name and type is one Salt DNS's mail-preset TSIG key may update (docs/integrations/mail.md there; a test checks it).

Where the values come from

The set

NameTypeNotes
_caldavs._tcp.<d> / _carddavs._tcp.<d>SRVDAV host and public port. Required.
_caldavs._tcp.<d> / _carddavs._tcp.<d>TXT"path=/dav/". Required.
_imaps._tcp.<d> (or _imap for STARTTLS)SRVOnly while IMAP is advertised. Required.
_submissions._tcp.<d> (or _submission)SRVOnly while SMTP submission is advertised. Required.
_pop3s._tcp.<d>SRVOnly while POP3 over TLS is advertised. Optional.
autoconfig.<d>CNAMETo the Kantoor host. Required.
autodiscover.<d>CNAMEOptional (Outlook).
_autodiscover._tcp.<d>SRVOptional (Outlook fallback).

The _imap and _submission names are RFC 6186's STARTTLS variants, used only when the advertised socket is :starttls; they never mean an unencrypted service. POP3 with STARTTLS (_pop3) is not generated: Salt DNS's mail preset does not grant that name. When DAV is served over plain HTTP (a development endpoint) there is no TLS name to publish, so no DAV records.

Disabled protocols: "service not available"

RFC 6186 section 3.1 lets a domain say that a service does NOT exist with an SRV record whose target is . (0 0 0 .). Decision: for IMAP, POP3 and SMTP submission that Kantoor does not advertise, the set contains such a marker (service: :unavailable, required: false) for the TLS name. It is optional because a domain can legitimately be served elsewhere for that protocol, and it is therefore never applied by a provider and is rendered as a comment in the zone text. An operator who wants clients to stop probing uncomments it. Nothing is invented for DAV or Autodiscover: those are always on.

Summary

Functions

The records of services Kantoor offers (without the RFC 6186 "not available" markers).

Canonical comparison form of a record's content: names lower-cased without the trailing dot, runs of blanks collapsed, TXT as its unquoted strings joined.

Settings under config :kantoor, :dns_records.

The records for domain, in a stable order (required first by group).

Normalises a domain name (case, trailing dot); :error when it is not a host name.

A zone-file fragment (RFC 1035 master file syntax) for records. Markers for services that are not available are written as comments.

Functions

applicable(records)

The records of services Kantoor offers (without the RFC 6186 "not available" markers).

canonical(type, content)

@spec canonical(String.t(), String.t()) :: String.t()

Canonical comparison form of a record's content: names lower-cased without the trailing dot, runs of blanks collapsed, TXT as its unquoted strings joined.

config()

@spec config() :: keyword()

Settings under config :kantoor, :dns_records.

for_domain(domain, opts \\ [])

@spec for_domain(String.t(), keyword()) ::
  {:ok, [Kantoor.DnsRecords.Record.t()]} | {:error, :invalid_domain}

The records for domain, in a stable order (required first by group).

Options: :ttl (default 3600), :autoconfig (overrides passed to Kantoor.Autoconfig.servers/1), :dav (a map like Kantoor.Autoconfig.dav/0).

normalize_domain(domain)

@spec normalize_domain(term()) :: {:ok, String.t()} | :error

Normalises a domain name (case, trailing dot); :error when it is not a host name.

zone_text(records)

@spec zone_text([Kantoor.DnsRecords.Record.t()]) :: String.t()

A zone-file fragment (RFC 1035 master file syntax) for records. Markers for services that are not available are written as comments.