Madness.Record (Madness v0.5.0)
View SourceRepresents a DNS resource record from an mDNS response.
Fields
:domain- The fully qualified domain name (e.g.,"mydevice.local","MyPrinter._http._tcp.local"):type- The record type as an atom. SeeMadness.rrtype/0for supported types.:class- The DNS class, typically:in(Internet):ttl- Time-to-live in seconds. Indicates how long the record may be cached. A TTL of 0 means the record should be considered expired/deleted.:data- The record data, with format depending on the record type:Type Data Format Example :aIPv4 address tuple {192, 168, 1, 100}:aaaaIPv6 address tuple {0x2001, 0xdb8, 0, 0, 0, 0, 0, 1}:ptrDomain name string "MyPrinter._http._tcp.local":srv{priority, weight, port, target}{0, 0, 80, "mydevice.local"}:txtList of strings ["path=/api", "version=1.0"]:cnameCanonical name string "alias.local":nsName server string "ns.local":mx{preference, exchange}{10, "mail.local"}:soaRaw binary (not parsed) <<...>>:nsecMapSet.t(non_neg_integer())of existing typesMapSet.new([1, 16]):metadata- Information about the record's origin. Seemetadata/0.:section(required) - Which section of the DNS response this record came from::answeror:additional:interface(required) - The network interface index the response was received on. Useful when querying on multiple interfaces.:source_ip(required) - The IP address of the host that sent the response, as an:inet.ip_address()tuple (e.g.,{192, 168, 1, 100}for IPv4 or{0x2001, 0xdb8, 0, 0, 0, 0, 0, 1}for IPv6).
Examples
# A record for a device
%Madness.Record{
domain: "mydevice.local",
type: :a,
class: :in,
ttl: 120,
data: {192, 168, 1, 100},
metadata: %{section: :answer, interface: 1, source_ip: {192, 168, 1, 100}}
}
# SRV record for a service
%Madness.Record{
domain: "MyPrinter._http._tcp.local",
type: :srv,
class: :in,
ttl: 120,
data: {0, 0, 631, "printer.local"},
metadata: %{section: :answer, interface: 1, source_ip: {192, 168, 1, 50}}
}
# TXT record with service metadata
%Madness.Record{
domain: "MyPrinter._http._tcp.local",
type: :txt,
class: :in,
ttl: 4500,
data: ["ty=EPSON Printer", "adminurl=http://printer.local"],
metadata: %{section: :additional, interface: 1, source_ip: {192, 168, 1, 50}}
}
Summary
Types
Metadata about the record's origin
The DNS response section the record came from
A DNS resource record from an mDNS response
Types
@type metadata() :: %{ section: section(), interface: non_neg_integer(), source_ip: :inet.ip_address() }
Metadata about the record's origin
@type section() :: :answer | :authority | :additional
The DNS response section the record came from
@type t() :: %Madness.Record{ class: :in | atom(), data: term(), domain: String.t(), metadata: metadata(), ttl: non_neg_integer(), type: Madness.rrtype() }
A DNS resource record from an mDNS response