Karta. MTASTS. Policy
(Karta v1.0.0)
An MTA-STS policy (RFC 8461 §3.2) and the check of an MX host against it (§4.1).
A policy is lines of key: value (LF or CRLF line endings):
version: STSv1
mode: enforce
mx: mail.example.com
mx: *.example.net
max_age: 1209600version (STSv1), mode (enforce, testing or none) and
max_age (seconds, at most 31,557,600; a larger value is lowered to it)
are required; mx may repeat and is required unless the mode is
none. Of a repeated field other than mx the first counts; unknown
fields are ignored; empty lines are allowed. A line that is not a
key: value pair, a value that is not printable ASCII, or an mx that
is not a host name (optionally *. and a host name) makes the whole
policy invalid.
id is the version the domain's TXT record announced when the policy
was fetched (Karta.MTASTS.TXT); text the policy as fetched.
Summary
Functions
True when host (an MX host name) matches one of the policy's mx
patterns: the same name, ignoring case and a final dot, or for
*.example.com any name of exactly one more label (mx1.example.com,
not example.com or a.b.example.com).
The longest max_age honoured, in seconds (one year).
Parses a policy. {:error, reason} says what is wrong, in words.
Types
@type mode() :: :enforce | :testing | :none
@type t() :: %Karta.MTASTS.Policy{ id: String.t() | nil, max_age: non_neg_integer(), mode: mode(), mx: [String.t()], text: String.t() }
Functions
True when host (an MX host name) matches one of the policy's mx
patterns: the same name, ignoring case and a final dot, or for
*.example.com any name of exactly one more label (mx1.example.com,
not example.com or a.b.example.com).
@spec max_age_limit() :: pos_integer()
The longest max_age honoured, in seconds (one year).
Parses a policy. {:error, reason} says what is wrong, in words.