Karta.DNS.Message (Karta v1.0.0)

A DNS message (RFC 1035 §4.1) as Karta.DNS.Wire encodes and decodes it.

  • Header flags are booleans; ad and cd are the DNSSEC bits of RFC 4035 §3.2 that Erlang's inet_dns does not expose.
  • rcode is the full response code: the 4 header bits plus, with EDNS, the 8 extended bits (RFC 6891 §6.1.3). Known codes are atoms (:noerror, :formerr, :servfail, :nxdomain, :notimp, :refused); others are integers.
  • additional never holds the OPT pseudo-record; it is decoded into edns instead (nil when the message has none).

Summary

Types

EDNS(0) parameters (RFC 6891): the requestor's UDP payload size, the version, the DNSSEC OK bit (RFC 3225) and options as {code, data}.

t()

Functions

A recursive query for one name and type, as Karta sends it: RD set, EDNS(0) with the DO bit and a 1232-octet UDP payload size (the DNS Flag Day 2020 value, which avoids IP fragmentation), and AD set so a validating resolver reports whether the answer is authenticated (RFC 6840 §5.7).

Types

edns()

@type edns() :: %{
  udp_size: 0..65535,
  version: 0..255,
  dnssec_ok: boolean(),
  options: [{0..65535, binary()}]
}

EDNS(0) parameters (RFC 6891): the requestor's UDP payload size, the version, the DNSSEC OK bit (RFC 3225) and options as {code, data}.

rcode()

@type rcode() ::
  :noerror | :formerr | :servfail | :nxdomain | :notimp | :refused | 0..4095

t()

@type t() :: %Karta.DNS.Message{
  aa: boolean(),
  ad: boolean(),
  additional: [Karta.DNS.Record.t()],
  answer: [Karta.DNS.Record.t()],
  authority: [Karta.DNS.Record.t()],
  cd: boolean(),
  edns: edns() | nil,
  id: 0..65535,
  opcode: 0..15,
  qr: boolean(),
  question: [Karta.DNS.Question.t()],
  ra: boolean(),
  rcode: rcode(),
  rd: boolean(),
  tc: boolean()
}

Functions

query(id, name, type, opts \\ [])

@spec query(0..65535, String.t(), Karta.DNS.Record.type(), keyword()) :: t()

A recursive query for one name and type, as Karta sends it: RD set, EDNS(0) with the DO bit and a 1232-octet UDP payload size (the DNS Flag Day 2020 value, which avoids IP fragmentation), and AD set so a validating resolver reports whether the answer is authenticated (RFC 6840 §5.7).