SaltDns. Proxy. Addresses
(Salt v1.0.0)
The address records of a proxy group: the public addresses of its nodes, the names they are published for, and the writing of the record sets.
Active for a group only when manage_addresses is on (default off). With it
off nothing here writes to any zone, except to remove record sets the feature
wrote earlier.
Flow
reconcile/2 is the one place that writes. It asks SaltDns.Proxy.Answer
which addresses the names get now (the nodes that are in, with the
never-empty safeguards), SaltDns.Proxy.AddressPlan which record sets that
means in each zone, and applies the result with one zone mutation per zone:
SaltDns.Zones.with_locked_zone/2 and apply_batch_locked/3 with the audit
source proxy, so serials, DNSSEC signing and the edges follow as for any
other change. The ownership rows (SaltDns.Proxy.PublishedRecord) are
written in the same transaction.
It runs after every change that matters (a node's state, its addresses, the routes, the extra names, the settings) and after every round of health checks, so a record someone deleted by hand is put back too.
report/1 computes the same plan without writing, for the console and API.
Addresses
An operator enters a node's public addresses (set_addresses/4); they pass
SaltDns.AddressFilter like the addresses of secondaries (public unicast
addresses, plus the allowlist the deployment configures for private ranges).
The address a node connected from (record_connection/2) is kept as a
suggestion only and is never published. It is the client address behind the
trusted proxy in plain form (an IPv4-mapped IPv6 address as IPv4), and a
private, loopback or otherwise unroutable address is never kept: it is the
proxy's, not the node's.
Summary
Functions
Adds an extra address name. It must lie in an active zone of the
organisation ({:error, changeset} with a name error otherwise).
The nodes of the group as SaltDns.Proxy.Answer takes them (retired nodes
are not part of the answer).
Returns a drained node to automatic: the checks decide again.
Forces a node out of the answers and keeps it out until automatic/3.
The node's stored state in the shape of SaltDns.Proxy.Health.
The extra address names of a group, by name.
The most addresses one node may have.
Brings the zones in line with the group: publishes the record sets for the
current answer and removes the feature's own sets that are no longer wanted.
One transaction per zone. Returns {:ok, summary} with the number of zones
changed and the errors by zone name. Does nothing for a group that does not
manage addresses and has written nothing.
Remembers where a node connected from, as a suggestion for the operator.
ip is the client address after the trusted-proxy handling
(SaltDnsWeb.Plugs.RemoteIp.client_ip/1). An IPv4-mapped IPv6 address is
stored as IPv4. An address SaltDns.AddressFilter would refuse (private,
loopback, link-local: the reverse proxy in front of Salt, typically) is not
stored, and clears a suggestion of that kind stored earlier. It is never
published.
The longest interval after which a connection address that has not changed is written
again (300 seconds). A group with a short status_max_age refreshes sooner:
refresh_seconds/1.
The refresh interval for a group whose nodes must have reported within status_max_age
seconds: min(300, status_max_age / 4). The time an address was seen is what corroborates
an HTTP-01 claim for status_max_age; refreshing it only every 300 seconds would let
the corroboration lapse and return with every refresh when the window is as short as the
group's minimum (60 seconds). A quarter of the window leaves three missed refreshes of
margin.
Removes every record set the group's feature wrote, whatever the setting (used before a group is deleted).
Removes an extra address name (and, through the next reconcile, its own records).
What the group's address names look like now, without writing anything:
%{names: [entry], desired: result, zones: [...]} where an entry is
%{name, sources, zone, status} and status is as in SaltDns.Proxy.AddressPlan
(:published/:unchanged with the records now published for the name,
:conflict with what is there, or :refused).
Sets the public addresses of a node (text, IPv4 and/or IPv6). Replaces the
list. Refused with {:error, {:invalid_address, [{address, reason}]}} when
one is not an IP address or not allowed by SaltDns.AddressFilter.
The organisation's zone names an address name could live in (for forms).
Types
@type result(t) :: {:ok, t} | {:error, Ecto.Changeset.t() | atom() | tuple()}
Functions
@spec add_extra_name(SaltDns.Proxy.Group.t(), String.t(), SaltDns.Zones.Actor.t()) :: result(SaltDns.Proxy.ExtraName.t())
Adds an extra address name. It must lie in an active zone of the
organisation ({:error, changeset} with a name error otherwise).
@spec answer_inputs([SaltDns.Shaker.Node.t()]) :: [SaltDns.Proxy.Answer.node_input()]
The nodes of the group as SaltDns.Proxy.Answer takes them (retired nodes
are not part of the answer).
@spec automatic( SaltDns.Proxy.Group.t(), SaltDns.Shaker.Node.t(), SaltDns.Zones.Actor.t() ) :: result(SaltDns.Shaker.Node.t())
Returns a drained node to automatic: the checks decide again.
@spec drain(SaltDns.Proxy.Group.t(), SaltDns.Shaker.Node.t(), SaltDns.Zones.Actor.t()) :: result(SaltDns.Shaker.Node.t())
Forces a node out of the answers and keeps it out until automatic/3.
@spec health_of(SaltDns.Shaker.Node.t()) :: SaltDns.Proxy.Health.state()
The node's stored state in the shape of SaltDns.Proxy.Health.
@spec list_extra_names(SaltDns.Proxy.Group.t()) :: [SaltDns.Proxy.ExtraName.t()]
The extra address names of a group, by name.
@spec max_addresses() :: pos_integer()
The most addresses one node may have.
@spec reconcile(SaltDns.Proxy.Group.t() | integer(), SaltDns.Zones.Actor.t()) :: {:ok, %{changed: non_neg_integer(), errors: [{String.t(), term()}]}}
Brings the zones in line with the group: publishes the record sets for the
current answer and removes the feature's own sets that are no longer wanted.
One transaction per zone. Returns {:ok, summary} with the number of zones
changed and the errors by zone name. Does nothing for a group that does not
manage addresses and has written nothing.
@spec record_connection(SaltDns.Shaker.Node.t(), :inet.ip_address() | nil) :: :ok
Remembers where a node connected from, as a suggestion for the operator.
ip is the client address after the trusted-proxy handling
(SaltDnsWeb.Plugs.RemoteIp.client_ip/1). An IPv4-mapped IPv6 address is
stored as IPv4. An address SaltDns.AddressFilter would refuse (private,
loopback, link-local: the reverse proxy in front of Salt, typically) is not
stored, and clears a suggestion of that kind stored earlier. It is never
published.
The time the address was seen is kept fresh: it is written when the address changes
and again when the stored time is older than refresh_seconds/1 of the node's group
(min(300, status_max_age / 4); 300 for a node without a group), whenever this is
called (on connect and with every verified status of a connected node), so an HTTP-01
claim stays corroborated (SaltDns.Certificates.Http01.Claims) for as long as the node
stays connected from the address. One conditional UPDATE: a status that finds the time
fresh writes nothing.
@spec refresh_seconds() :: pos_integer()
The longest interval after which a connection address that has not changed is written
again (300 seconds). A group with a short status_max_age refreshes sooner:
refresh_seconds/1.
@spec refresh_seconds(pos_integer()) :: pos_integer()
The refresh interval for a group whose nodes must have reported within status_max_age
seconds: min(300, status_max_age / 4). The time an address was seen is what corroborates
an HTTP-01 claim for status_max_age; refreshing it only every 300 seconds would let
the corroboration lapse and return with every refresh when the window is as short as the
group's minimum (60 seconds). A quarter of the window leaves three missed refreshes of
margin.
@spec remove_all(SaltDns.Proxy.Group.t(), SaltDns.Zones.Actor.t()) :: {:ok, map()}
Removes every record set the group's feature wrote, whatever the setting (used before a group is deleted).
@spec remove_extra_name(SaltDns.Proxy.Group.t(), String.t(), SaltDns.Zones.Actor.t()) :: result(SaltDns.Proxy.ExtraName.t())
Removes an extra address name (and, through the next reconcile, its own records).
@spec report(SaltDns.Proxy.Group.t()) :: map()
What the group's address names look like now, without writing anything:
%{names: [entry], desired: result, zones: [...]} where an entry is
%{name, sources, zone, status} and status is as in SaltDns.Proxy.AddressPlan
(:published/:unchanged with the records now published for the name,
:conflict with what is there, or :refused).
@spec set_addresses( SaltDns.Proxy.Group.t(), SaltDns.Shaker.Node.t(), [String.t()], SaltDns.Zones.Actor.t() ) :: result(SaltDns.Shaker.Node.t())
Sets the public addresses of a node (text, IPv4 and/or IPv6). Replaces the
list. Refused with {:error, {:invalid_address, [{address, reason}]}} when
one is not an IP address or not allowed by SaltDns.AddressFilter.
@spec zone_names(SaltDns.Proxy.Group.t()) :: [String.t()]
The organisation's zone names an address name could live in (for forms).