SaltDns.Registrar.NameServers (Salt v1.0.0)

The name servers of a domain at its registrar, with the glue addresses that belong to them.

A name server is a map with :name and the optional :ipv4 and :ipv6:

%{name: "ns1.example.org", ipv4: "192.0.2.1", ipv6: nil}

A caller may give a plain host name instead, as Salt has always accepted; it becomes an entry with no addresses. Names are normalised with SaltDns.Registrar.Name.normalise/1; an address is parsed and written in its canonical form.

Glue

A name server that is the domain itself or under it is in bailiwick. The registry cannot find it without its address, so an in-bailiwick name server without an IPv4 or IPv6 address is refused. A name server outside the domain needs no glue, and a registry ignores or refuses an address sent for it: an address on an out-of-bailiwick name server is refused too, never silently dropped, so that what a caller asked for and what the registrar is sent stay the same.

What a reading keeps

When a domain is read back from the registrar, the addresses it reports are kept with the domain (name_server_addresses). prepare/3 carries a stored address forward when the caller names the same name server again without one, so a later name-server change does not silently drop the glue. An address the caller gives replaces the stored one for that family.

Summary

Functions

The addresses to keep and to send, keyed by name server, for the in-bailiwick entries that have one. Out-of-bailiwick addresses are not glue and are left out. The value is %{"ipv4" => ..., "ipv6" => ...} with only the families present.

True when name is fqdn itself or under it, where glue is needed.

True when at least one entry carries an address (the part a fingerprint must cover).

The names of the entries, in order.

Validates and normalises a list of name servers: a plain host name, or a map with :name and the optional :ipv4 and :ipv6. Nothing is checked against a domain here (see prepare/3).

Validates and normalises name servers for fqdn: plain host names or entries with :name and the optional :ipv4 and :ipv6 (atom or string keys). nil is an empty list; [] when registering or transferring means the registrar's own default name servers.

Types

t()

@type t() :: %{name: String.t(), ipv4: String.t() | nil, ipv6: String.t() | nil}

Functions

addresses(entries, fqdn)

@spec addresses([t()], String.t()) :: %{optional(String.t()) => map()}

The addresses to keep and to send, keyed by name server, for the in-bailiwick entries that have one. Out-of-bailiwick addresses are not glue and are left out. The value is %{"ipv4" => ..., "ipv6" => ...} with only the families present.

bailiwick?(name, fqdn)

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

True when name is fqdn itself or under it, where glue is needed.

glue?(entries)

@spec glue?([t()]) :: boolean()

True when at least one entry carries an address (the part a fingerprint must cover).

names(entries)

@spec names([t()]) :: [String.t()]

The names of the entries, in order.

normalise(entries)

@spec normalise(term()) :: {:ok, [t()]} | {:error, {:invalid, map()}}

Validates and normalises a list of name servers: a plain host name, or a map with :name and the optional :ipv4 and :ipv6. Nothing is checked against a domain here (see prepare/3).

prepare(input, fqdn, stored \\ %{})

@spec prepare(term(), String.t(), map()) :: {:ok, [t()]} | {:error, {:invalid, map()}}

Validates and normalises name servers for fqdn: plain host names or entries with :name and the optional :ipv4 and :ipv6 (atom or string keys). nil is an empty list; [] when registering or transferring means the registrar's own default name servers.

stored is the address map kept with the domain (name_server_addresses). An entry that omits an address takes the stored address of the same family for that name.