Karta.DNS.Answer (Karta v1.0.0)

The result of looking up one name and type.

  • status - :ok (records found), :nodata (the name exists, the type does not) or :nxdomain (the name does not exist).
  • records - the data of each matching record (see Karta.DNS.Record), in the order received.
  • canonical_name - the name the records belong to after following CNAMEs (RFC 1034 §3.6.2); the queried name when there was none. DANE (RFC 7672 §2.2.2) needs it.
  • ttl - seconds the answer may be cached: the lowest TTL of the records and CNAMEs used; for a negative answer the lower of the SOA's TTL and its MINIMUM field (RFC 2308 §5). nil when a negative answer carries no SOA: such an answer must not be cached.
  • secure - the resolver set the AD bit: every record in the answer, or the proof that there is none, was validated with DNSSEC. Only as trustworthy as the path to the resolver (see Karta.DNS.Resolver.Unbound).

Summary

Functions

Builds the answer to the question name/type from a response.

Compares two names in presentation form, ignoring ASCII case and a final dot.

Types

status()

@type status() :: :ok | :nodata | :nxdomain

t()

@type t() :: %Karta.DNS.Answer{
  canonical_name: String.t(),
  name: String.t(),
  records: [term()],
  secure: boolean(),
  status: status(),
  ttl: non_neg_integer() | nil,
  type: Karta.DNS.Record.type()
}

Functions

from_message(message, name, type)

@spec from_message(Karta.DNS.Message.t(), String.t(), Karta.DNS.Record.type()) ::
  {:ok, t()} | {:error, Karta.DNS.Resolver.error()}

Builds the answer to the question name/type from a response.

Only records on the CNAME chain that starts at name are used; anything else in the answer section is ignored. A response code other than NOERROR or NXDOMAIN is an error (:servfail, :refused, :formerr, :notimp or {:rcode, code}), as is a CNAME chain longer than 8 or a name with two CNAMEs (:malformed).

same_name?(a, b)

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

Compares two names in presentation form, ignoring ASCII case and a final dot.