SaltDns.Ownership.Check (Salt v1.0.0)

The pure rules of zone ownership checks (decision D15).

A zone is shown to belong to an organisation in one of two ways:

  • delegation: the NS names the zone's parent publishes for it (read from the parent's own servers, see SaltDns.Resolver.Delegation; a resolver would ask the zone's servers, which do not serve a pending zone) include at least two of Salt DNS's own nameservers (config :salt_dns, :nameservers); with fewer than two configured, all of them are required;
  • challenge: a TXT record at _salt-dns-challenge.<zone> holds the zone's verification token. Customers who keep other nameservers use this.

This module only judges what the resolver returned and does the date arithmetic; SaltDns.Ownership does the asking and the writing.

Summary

Functions

Seconds to wait before check number attempt + 1: 1 minute, 5, 15, one hour, then hourly.

Whether one of the TXT values is the token. The comparison is exact apart from surrounding white space and one pair of quotes (some control panels add them).

The name that carries the challenge for zone.

Judges the NS names found for a zone against the configured nameservers. Returns {:ok, matched} or {:insufficient, matched}; names compare case-insensitively, ignoring a trailing dot. With no nameservers configured nothing can be delegated: :disabled.

True when proof has been missing since since for at least grace_days.

When the next automatic check is due, or :expired when it would fall after started_at + window_days.

How many of the configured nameservers a delegation must include.

Functions

backoff(attempt)

@spec backoff(non_neg_integer()) :: pos_integer()

Seconds to wait before check number attempt + 1: 1 minute, 5, 15, one hour, then hourly.

challenge(values, token)

@spec challenge([String.t()], String.t()) :: :match | :missing

Whether one of the TXT values is the token. The comparison is exact apart from surrounding white space and one pair of quotes (some control panels add them).

challenge_name(zone)

@spec challenge_name(String.t()) :: String.t()

The name that carries the challenge for zone.

delegation(found, configured)

@spec delegation([String.t()], [String.t()]) ::
  {:ok, [String.t()]} | {:insufficient, [String.t()]} | :disabled

Judges the NS names found for a zone against the configured nameservers. Returns {:ok, matched} or {:insufficient, matched}; names compare case-insensitively, ignoring a trailing dot. With no nameservers configured nothing can be delegated: :disabled.

lost?(since, now, grace_days)

@spec lost?(DateTime.t() | nil, DateTime.t(), pos_integer()) :: boolean()

True when proof has been missing since since for at least grace_days.

next_check(attempt, started_at, now, window_days)

@spec next_check(non_neg_integer(), DateTime.t(), DateTime.t(), pos_integer()) ::
  {:in, pos_integer()} | :expired

When the next automatic check is due, or :expired when it would fall after started_at + window_days.

required_nameservers(configured)

@spec required_nameservers([String.t()]) :: non_neg_integer()

How many of the configured nameservers a delegation must include.