SaltDns. Knot. Protocol
(Salt v1.0.0)
Pure helpers for talking to Knot 3.6 through knotc: validating names,
building argument lists, parsing output and classifying errors.
Output formats and error texts were checked against Knot DNS 3.6.2 (see the control-socket note in the project's planning documents).
Summary
Functions
Builds the knotc arguments for one change in zone.
Classifies a failed knotc call by its Knot 3.6 error text.
True for a record type that Knot manages in a signed zone.
The record types Knot creates and owns in a signed zone. They are never
part of the desired data in Postgres; SaltDns.Knot.read_zone/1 returns
them for a signed zone, and callers comparing zone contents must drop them.
Appends the root dot, tolerating a name that already has one.
True if the zone has an SOA among the records returned by parse_zone_read/1.
Future key timers as events %{event, key_tag, in_seconds}, soonest first.
Parses CDNSKEY rdata 257 3 13 <base64>.
Parses knotc conf-read zone[<zone>].dnssec-signing /
.dnssec-policy output (zone[x.].dnssec-policy salt-nsec3) to the value.
Empty output means the item is not set.
Parses CDS rdata 15350 13 2 F51A... (digest lower-cased).
Parses keymgr -j <zone> list (a JSON array) into key maps
Pending zone events from knotc -e zone-status (re-sign: +12D12h23m42s),
as %{event, key_tag: nil, in_seconds}. Events shown as - are not pending.
Parses knotc zone-read output into :add changes.
Parses knotc zone-status <zone> output, e.g.
[example.com.] role: master | serial: 1794337202 | catalog: @cat.invalid.
The SOA rdata for ensure_zone/2, with a serial.
Validates a record owner name (a leading * label is allowed).
Validates a zone name: absolute, lower-case, no trailing dot, no wildcard.
Functions
@spec change_args(String.t(), SaltDns.Zones.Change.t()) :: {:ok, [String.t()]} | {:error, term()}
Builds the knotc arguments for one change in zone.
Adding is zone-set <zone> <owner> <ttl> <type> <rdata>; removing is
zone-unset <zone> <owner> <type> <rdata>. The rdata is one argument.
@spec classify_error(term()) :: :no_such_zone | :transaction_in_progress | :no_transaction | :exists | :absent | :no_node | :no_ksk_ready | :duplicate_identifier | :invalid_identifier | :other
Classifies a failed knotc call by its Knot 3.6 error text.
:exists and :absent are the two idempotent outcomes of zone-set and
zone-unset.
True for a record type that Knot manages in a signed zone.
@spec dnssec_types() :: [String.t()]
The record types Knot creates and owns in a signed zone. They are never
part of the desired data in Postgres; SaltDns.Knot.read_zone/1 returns
them for a signed zone, and callers comparing zone contents must drop them.
Appends the root dot, tolerating a name that already has one.
@spec has_soa?([SaltDns.Zones.Change.t()]) :: boolean()
True if the zone has an SOA among the records returned by parse_zone_read/1.
Future key timers as events %{event, key_tag, in_seconds}, soonest first.
Parses CDNSKEY rdata 257 3 13 <base64>.
Parses knotc conf-read zone[<zone>].dnssec-signing /
.dnssec-policy output (zone[x.].dnssec-policy salt-nsec3) to the value.
Empty output means the item is not set.
Parses CDS rdata 15350 13 2 F51A... (digest lower-cased).
Parses keymgr -j <zone> list (a JSON array) into key maps:
%{id, tag, role: :ksk | :zsk | :csk, algorithm, state, timers: %{...}}state is derived from the timers at now (unix seconds): :created,
:pre_active, :published, :ready (a KSK waiting for its DS to be
confirmed, see zone-ksk-submitted), :active, :retiring, :retired,
:removed. timers maps the timer names (atoms) to unix seconds, absent
when unset (0 in keymgr).
Pending zone events from knotc -e zone-status (re-sign: +12D12h23m42s),
as %{event, key_tag: nil, in_seconds}. Events shown as - are not pending.
@spec parse_zone_read(String.t()) :: {:ok, [SaltDns.Zones.Change.t()]} | {:error, {:unparseable, String.t()}}
Parses knotc zone-read output into :add changes.
Each line is <owner> <ttl> <type> <rdata>; owners are absolute with a
trailing dot (stripped here).
@spec parse_zone_status(String.t()) :: {:ok, SaltDns.Knot.zone_status()} | {:error, {:unparseable, String.t()}}
Parses knotc zone-status <zone> output, e.g.
[example.com.] role: master | serial: 1794337202 | catalog: @cat.invalid.
@spec soa_rdata(SaltDns.Knot.soa(), non_neg_integer()) :: String.t()
The SOA rdata for ensure_zone/2, with a serial.
Validates a record owner name (a leading * label is allowed).
Validates a zone name: absolute, lower-case, no trailing dot, no wildcard.