A resolver that answers from a map, for tests and for checking mail offline.
The map's keys are names. Each value is a list of {type, value} entries, or
one of :nxdomain, :temperror or :timeout for the whole name:
records = %{
"example.com" => [txt: "v=spf1 ip4:192.0.2.0/24 -all", mx: {10, "mx.example.com"}],
"mx.example.com" => [a: {192, 0, 2, 1}],
"_dmarc.example.com" => [txt: "v=DMARC1; p=reject"],
"broken.example" => :temperror
}
MailAuth.authenticate(raw, resolver: MailAuth.Resolver.Static, records: records)A TXT value can be a list of strings; they are joined, as the strings of one
TXT record are. An entry can also be {type, :temperror} to fail one type.
A {:cname, target} entry is followed when the name has no records of the
type asked for.
Names not in the map are :nxdomain. A name in the map with no entries of
the type asked for is :no_data. Names are matched without case and without
a trailing dot.
Instead of the :records option, the map can be set for the current process
with put_records/1. Tasks started from that process see it too.
Summary
Functions
Parses a file of records, one per line: name TYPE value.
Parses records in the format of parse_file/1 from a string.
Sets the records for the current process.
Functions
Parses a file of records, one per line: name TYPE value.
TXT values may be written in double quotes, and several quoted strings are
joined. MX values are preference exchange. A, AAAA and PTR values are as
written. Empty lines and lines starting with # are skipped.
brisbane._domainkey.example.com TXT "v=DKIM1; p=MIGfMA0..."
example.com MX 10 mx.example.com
mx.example.com A 192.0.2.1
Parses records in the format of parse_file/1 from a string.
@spec put_records(map()) :: :ok
Sets the records for the current process.