Karta.DNS.Publish (Karta v1.0.0)

Publishes Karta's own DNS records of a verified sending domain in the zone that holds it on the DNS server the instance publishes through (Karta.DNS.Provider), when that zone is one the operator allows:

SPF, DMARC and MX records are not written: they hold the domain owner's other senders and policies, so the DNS health checks suggest them instead. Nothing is published for a domain that is not verified: its organisation has not shown that the name is theirs.

What Karta owns. Every RRset Karta writes carries an owner tag naming the domain (Karta.DNS.RRSet); the provider stores it in whatever its server has (a PowerDNS comment, the RFC 2136 provider's inventory record). Karta replaces and removes only tagged RRsets. An RRset at one of its names that someone else wrote is taken over when it already holds exactly Karta's records, and left alone otherwise (a conflict, reported with the reason). Karta's RRsets that are no longer needed (a retired key's, a removed tracking host's) are removed. No other name or type is touched.

Dry run, then publish. plan/2 compares and returns the changes; publish/2 writes them, all changes to a zone in one call (the provider applies it whole or not at all). With nothing to change nothing is sent, so a second run is a no-op and the zone's serial stays as it is.

The last publication's result is kept on the domain (dns_synced_at; dns_failure and dns_failed_at when it failed or left records alone) and announced on its topic (:domain).

Summary

Functions

True when Karta publishes the domain's records: publishing is configured and the domain is in an allowed zone (or under one).

The changes publishing would make (a dry run): {:ok, changes}, sorted by name and type, or {:error, :off} (not configured, or not in an allowed zone), {:error, :not_verified} or {:error, text} (the server could not be asked, or refuses the zone). Options: config (instead of the provider's own) and provider (instead of the selected one).

Publishes: writes the changes of plan/2 (all but the conflicts) and records the result on the domain. Returns every change, conflicts included. Options: config, provider, now, and expected (the changes someone looked at: when the writes differ from theirs now, nothing is written and the result is {:error, :changed}).

The RRsets Karta publishes for the domain (see the module doc).

The TTL of the records Karta publishes, in seconds.

Functions

allowed?(domain, config \\ Provider.config())

True when Karta publishes the domain's records: publishing is configured and the domain is in an allowed zone (or under one).

plan(domain, opts \\ [])

@spec plan(Karta.Domains.Domain.t(), keyword()) ::
  {:ok, [Karta.DNS.Change.t()]} | {:error, :off | :not_verified | String.t()}

The changes publishing would make (a dry run): {:ok, changes}, sorted by name and type, or {:error, :off} (not configured, or not in an allowed zone), {:error, :not_verified} or {:error, text} (the server could not be asked, or refuses the zone). Options: config (instead of the provider's own) and provider (instead of the selected one).

publish(domain, opts \\ [])

@spec publish(Karta.Domains.Domain.t(), keyword()) ::
  {:ok, [Karta.DNS.Change.t()]}
  | {:error, :off | :not_verified | :changed | String.t()}

Publishes: writes the changes of plan/2 (all but the conflicts) and records the result on the domain. Returns every change, conflicts included. Options: config, provider, now, and expected (the changes someone looked at: when the writes differ from theirs now, nothing is written and the result is {:error, :changed}).

records(domain)

@spec records(Karta.Domains.Domain.t()) :: [Karta.DNS.RRSet.t()]

The RRsets Karta publishes for the domain (see the module doc).

ttl()

@spec ttl() :: pos_integer()

The TTL of the records Karta publishes, in seconds.