SaltDns. Resolver behaviour
(Salt v1.0.0)
What a recursive resolver says about a name: the behaviour ownership checks use, so tests can run them without a network.
Two questions are enough: the NS names of a zone (ns/1) and the TXT
strings at a name (txt/1). Both return {:ok, list}; an empty list means
the resolver answered and there is nothing (no such name, or no such
records). {:error, reason} means no usable answer: :unavailable (no
resolver is configured), :timeout, :servfail (the resolver could not
resolve it, including a DNSSEC failure) or :refused. Callers treat errors
as inconclusive, never as proof that something is missing.
The implementation is chosen with config :salt_dns, :resolver: the real
SaltDns.Resolver.DNS by default, SaltDns.Resolver.Fake in tests.
Summary
Types
The parent's answer about a child's DS, one entry per authoritative server
of the parent: the DS records it holds (ttl is the smallest DS TTL) or,
when it has none, the negative TTL of its SOA (RFC 2308).
One server address of a zone's delegation and what it said: host is the NS
name, address the IP literal asked (nil when the host has no usable
address), server the two together for messages.
Callbacks
The NS names the zone's parent delegates name to (its referral). This
is how a delegation is proven for a zone that is not served yet; see
SaltDns.Resolver.Delegation.
The DS records the parent's authoritative servers publish for name
(all of them are asked, recursion off). Any server that cannot answer makes
the result an error: the DNSSEC lifecycle never acts on a partial view.
NS names (lower case, no trailing dot) of the zone name, as a recursive
resolver sees them: the answer of the zone's own nameservers.
The TXT strings at name; the character-strings of one record are joined.
The TXT strings at name as each authoritative server of its zone says
them (recursion off): {:ok, [%{server: address, result: result}]}, one entry
per server, in the order the zone's NS records give them (the servers are those
the public DNS names for the zone, secondaries and edges included). Used to
wait until a new record has reached every server before an ACME provider is told
to look.
The CAA records at the apex of zone from every address of every nameserver the
public DNS delegates zone to, same shape and errors as zone_txt_each/2; each
result is a list of record strings (0 issue "ca.test"). Used to wait until a
change to the CAA records has reached every server before an order goes on.
The TXT strings at name, which lies inside the zone zone (the DNS-01
challenge name), from every address of every nameserver the public DNS
delegates zone to (the parent's referral, IPv4 and IPv6). Unlike
txt_each_authoritative/1, which asks the servers of the zone enclosing
name's parent, this asks the servers of the zone itself, which is where a
certificate authority looks. {:error, :not_delegated} when the public DNS
names no nameserver for zone; other errors mean the delegation could not be
read. An address the host cannot reach is {:error, :unreachable}.
Functions
The NS names the parent of name delegates to.
The parent's DS records for name, from each of the parent's servers.
The NS names of name, from its own nameservers.
The TXT values at name.
The TXT values at name from every authoritative server of its zone.
The CAA records at the apex of zone from every nameserver address of its delegation.
The TXT values at name from every nameserver address the public DNS delegates zone to.
Types
@type ds_result() :: %{ servers: non_neg_integer(), results: [ %{ ds: [ %{ key_tag: non_neg_integer(), algorithm: non_neg_integer(), digest_type: non_neg_integer(), digest: String.t(), ttl: non_neg_integer() } ], ttl: non_neg_integer() | nil, negative_ttl: non_neg_integer() | nil } ] }
The parent's answer about a child's DS, one entry per authoritative server
of the parent: the DS records it holds (ttl is the smallest DS TTL) or,
when it has none, the negative TTL of its SOA (RFC 2308).
@type reason() ::
:unavailable
| :timeout
| :servfail
| :refused
| :malformed
| :lame
| :no_parent
| :unreachable
| :not_delegated
| :no_address
@type server_answer() :: %{ host: String.t(), address: String.t() | nil, server: String.t(), result: result() }
One server address of a zone's delegation and what it said: host is the NS
name, address the IP literal asked (nil when the host has no usable
address), server the two together for messages.
Callbacks
The NS names the zone's parent delegates name to (its referral). This
is how a delegation is proven for a zone that is not served yet; see
SaltDns.Resolver.Delegation.
The DS records the parent's authoritative servers publish for name
(all of them are asked, recursion off). Any server that cannot answer makes
the result an error: the DNSSEC lifecycle never acts on a partial view.
NS names (lower case, no trailing dot) of the zone name, as a recursive
resolver sees them: the answer of the zone's own nameservers.
The TXT strings at name; the character-strings of one record are joined.
@callback txt_each_authoritative(name :: String.t()) :: {:ok, [%{server: String.t(), result: result()}]} | {:error, reason()}
The TXT strings at name as each authoritative server of its zone says
them (recursion off): {:ok, [%{server: address, result: result}]}, one entry
per server, in the order the zone's NS records give them (the servers are those
the public DNS names for the zone, secondaries and edges included). Used to
wait until a new record has reached every server before an ACME provider is told
to look.
@callback zone_caa_each(zone :: String.t()) :: {:ok, [server_answer()]} | {:error, reason()}
The CAA records at the apex of zone from every address of every nameserver the
public DNS delegates zone to, same shape and errors as zone_txt_each/2; each
result is a list of record strings (0 issue "ca.test"). Used to wait until a
change to the CAA records has reached every server before an order goes on.
@callback zone_txt_each(zone :: String.t(), name :: String.t()) :: {:ok, [server_answer()]} | {:error, reason()}
The TXT strings at name, which lies inside the zone zone (the DNS-01
challenge name), from every address of every nameserver the public DNS
delegates zone to (the parent's referral, IPv4 and IPv6). Unlike
txt_each_authoritative/1, which asks the servers of the zone enclosing
name's parent, this asks the servers of the zone itself, which is where a
certificate authority looks. {:error, :not_delegated} when the public DNS
names no nameserver for zone; other errors mean the delegation could not be
read. An address the host cannot reach is {:error, :unreachable}.
Functions
The NS names the parent of name delegates to.
The parent's DS records for name, from each of the parent's servers.
The NS names of name, from its own nameservers.
The TXT values at name.
@spec txt_each_authoritative(String.t()) :: {:ok, [%{server: String.t(), result: result()}]} | {:error, reason()}
The TXT values at name from every authoritative server of its zone.
@spec zone_caa_each(String.t()) :: {:ok, [server_answer()]} | {:error, reason()}
The CAA records at the apex of zone from every nameserver address of its delegation.
@spec zone_txt_each(String.t(), String.t()) :: {:ok, [server_answer()]} | {:error, reason()}
The TXT values at name from every nameserver address the public DNS delegates zone to.