SaltDns.Zones.Name (Salt v1.0.0)

Domain name handling: normalisation to lower-case A-labels without a trailing dot, label and length limits (RFC 1035, RFC 2181), and zone membership.

This is the only module that talks to the IDNA library. Input U-labels are converted to A-labels with UTS #46 (non-transitional processing); to_unicode/1 converts back for display.

Labels are limited to letters, digits, hyphen and underscore (underscore for service labels such as _dmarc), with no leading or trailing hyphen. RFC 2181 would allow any octet, but such labels are almost always mistakes and are awkward to present safely. The root name is "".

Summary

Functions

The presentation form of a normalised name inside rdata: absolute, with a trailing dot.

True when name is zone or below it. Both must be normalised.

Joins a subname to a zone name. The empty subname and @ mean the apex.

Normalises a name.

Converts A-labels back to U-labels for display. Invalid labels are left as they are.

Types

error()

@type error() :: {atom(), String.t()}

Functions

absolute(name)

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

The presentation form of a normalised name inside rdata: absolute, with a trailing dot.

in_zone?(name, zone)

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

True when name is zone or below it. Both must be normalised.

join(subname, zone)

@spec join(String.t(), String.t()) :: String.t()

Joins a subname to a zone name. The empty subname and @ mean the apex.

normalise(name, opts \\ [])

@spec normalise(term(), keyword()) :: {:ok, String.t()} | {:error, error()}

Normalises a name.

Options:

  • :allow_root - accept "." and return "" (default false)
  • :wildcard - accept a left-most * label (default false)

to_unicode(name)

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

Converts A-labels back to U-labels for display. Invalid labels are left as they are.