SaltDns.Rfc2136.Zone (Salt v1.0.0)

An in-memory snapshot of one zone, the input of SaltDns.Rfc2136.Update and SaltDns.Rfc2136.Query.

rrsets maps {owner_name, type} to {ttl, [rdata]}:

  • owner_name is the canonical name: labels lower-cased and re-escaped by :dns_domain.join/1, no trailing dot.
  • type is the numeric RR type (SaltDns.Rfc2136.Rec).
  • rdata are dns_erlang rdata structs made canonical on the way in (normalize_rdata/1 lower-cases every domain-name field), kept sorted and unique, so RRsets compare as sets and TTL is ignored when comparing (RFC 2136 section 3.2.3).

Names are always compared label by label with :dns_domain.split/1, never by string suffix, so x\.example.com (one label containing a dot) is not inside example.com.

Summary

Functions

Applies a change list as Update.process/3 returns it: removes first, then adds; an add sets the RRset's TTL. Used by tests and by callers that keep a snapshot current.

Removes an RRset.

Builds a snapshot from #dns_rr{} records. Names must be inside the zone (ArgumentError otherwise). Differing TTLs in one RRset are reduced to the lowest (RFC 2181 section 5.2); duplicate rdata collapse.

True when some existing name is strictly below name (an empty non-terminal if name owns nothing).

True when labels is the zone apex or below it.

The lower-cased labels of name (unescaped, trailing dot ignored).

True when at least one RR is owned by name (empty non-terminals do not count).

An empty snapshot of the zone name.

Lower-cases every domain-name field of an rdata struct.

Like labels/1, but :error for a name dns_erlang cannot parse (for example an empty label).

Stores an RRset (rdata normalised, sorted, unique); an empty list deletes it.

All RRsets as #dns_rr{} records, sorted.

The {ttl, [rdata]} of an RRset, or nil. name must be canonical.

The apex SOA as {ttl, rdata}, or nil.

The upper-case mnemonic of a type number ("TYPE65280" when unknown).

The type number of a mnemonic produced by type_name/1.

The RR types present at name, sorted.

Types

change()

@type change() :: {:add | :remove, String.t(), String.t(), non_neg_integer(), rdata()}

rdata()

@type rdata() :: term()

rrset()

@type rrset() :: {non_neg_integer(), [rdata()]}

t()

@type t() :: %SaltDns.Rfc2136.Zone{
  by_name: %{required(String.t()) => MapSet.t(non_neg_integer())},
  labels: [binary()],
  name: String.t(),
  rrsets: %{required({String.t(), non_neg_integer()}) => rrset()}
}

Functions

apply_changes(zone, changes)

@spec apply_changes(t(), [change()]) :: t()

Applies a change list as Update.process/3 returns it: removes first, then adds; an add sets the RRset's TTL. Used by tests and by callers that keep a snapshot current.

delete_rrset(zone, name, type)

@spec delete_rrset(t(), String.t(), non_neg_integer()) :: t()

Removes an RRset.

from_records(name, records)

@spec from_records(String.t(), [tuple()]) :: t()

Builds a snapshot from #dns_rr{} records. Names must be inside the zone (ArgumentError otherwise). Differing TTLs in one RRset are reduced to the lowest (RFC 2181 section 5.2); duplicate rdata collapse.

has_descendants?(zone, name)

@spec has_descendants?(t(), String.t()) :: boolean()

True when some existing name is strictly below name (an empty non-terminal if name owns nothing).

in_zone?(labels, zone_labels)

@spec in_zone?([binary()], [binary()]) :: boolean()

True when labels is the zone apex or below it.

labels(name)

@spec labels(binary()) :: [binary()]

The lower-cased labels of name (unescaped, trailing dot ignored).

name_exists?(zone, name)

@spec name_exists?(t(), String.t()) :: boolean()

True when at least one RR is owned by name (empty non-terminals do not count).

new(name)

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

An empty snapshot of the zone name.

normalize_rdata(rdata)

@spec normalize_rdata(rdata()) :: rdata()

Lower-cases every domain-name field of an rdata struct.

parse_labels(name)

@spec parse_labels(term()) :: {:ok, [binary()]} | :error

Like labels/1, but :error for a name dns_erlang cannot parse (for example an empty label).

put_rrset(zone, name, type, arg)

@spec put_rrset(t(), String.t(), non_neg_integer(), rrset()) :: t()

Stores an RRset (rdata normalised, sorted, unique); an empty list deletes it.

records(zone)

@spec records(t()) :: [tuple()]

All RRsets as #dns_rr{} records, sorted.

rrset(zone, name, type)

@spec rrset(t(), String.t(), non_neg_integer()) :: rrset() | nil

The {ttl, [rdata]} of an RRset, or nil. name must be canonical.

soa(zone)

@spec soa(t()) :: {non_neg_integer(), rdata()} | nil

The apex SOA as {ttl, rdata}, or nil.

type_name(type)

@spec type_name(non_neg_integer()) :: String.t()

The upper-case mnemonic of a type number ("TYPE65280" when unknown).

type_number(name)

@spec type_number(String.t()) :: non_neg_integer()

The type number of a mnemonic produced by type_name/1.

types_at(zone, name)

@spec types_at(t(), String.t()) :: [non_neg_integer()]

The RR types present at name, sorted.