Karta. PublicSuffix
(Karta v1.0.0)
The Public Suffix List (https://publicsuffix.org/): the names under
which anyone can register a name of their own (com, co.uk,
github.io), and so the organisational domain of a name, the one its
owner registered (example.co.uk for mail.example.co.uk). DMARC looks
for a domain's policy there when the domain has none of its own
(RFC 7489 §3.2 and §6.6.3).
The list is vendored in priv/public_suffix/public_suffix_list.dat
(Mozilla Public License 2.0; its source and date are in the README next
to it) and read when this module is compiled: both sections, ICANN and
private, with U-labels converted to A-labels (Karta.PublicSuffix.Rules).
The list changes every week, so Karta also fetches it every day
(Karta.PublicSuffix.Refresh) and keeps the copy in the database
(Karta.PublicSuffix.Fetched); each node uses that copy once it has
loaded it (load/0: at start and every hour, Karta.PublicSuffix.Loader),
and the vendored list until then, or when no copy was ever fetched.
Lookups never touch the network or the database.
The algorithm is the list's own (https://publicsuffix.org/list/): of
the rules that match a name, an exception rule (!city.kobe.jp) wins,
else the one with the most labels; a name no rule matches falls under
the implicit rule * (its last label). Names are lower-case ASCII
without the final dot, as Karta.DNS.normalize_name/1 gives them.
Summary
Functions
Which list this node uses: %{source: :vendored}, or %{source: :fetched, sha256:, version:, fetched_at:} for the copy fetched.
Uses the copy in the database (Karta.PublicSuffix.Fetched) on this
node when it differs from the one in use, after checking it again
(Karta.PublicSuffix.Rules.check/1); without a copy the list in use
stays. Returns which list is in use (in_use/0).
The organisational (registrable) domain of name: its public suffix and
one more label ("example.co.uk" for "mail.example.co.uk"), or nil
when name is a public suffix itself ("co.uk", "com").
The public suffix of name: "co.uk" for "mail.example.co.uk";
the name itself when it is a public suffix.
How many rules the list in use has.
Functions
@spec in_use() :: map()
Which list this node uses: %{source: :vendored}, or %{source: :fetched, sha256:, version:, fetched_at:} for the copy fetched.
@spec load() :: map()
Uses the copy in the database (Karta.PublicSuffix.Fetched) on this
node when it differs from the one in use, after checking it again
(Karta.PublicSuffix.Rules.check/1); without a copy the list in use
stays. Returns which list is in use (in_use/0).
The organisational (registrable) domain of name: its public suffix and
one more label ("example.co.uk" for "mail.example.co.uk"), or nil
when name is a public suffix itself ("co.uk", "com").
The public suffix of name: "co.uk" for "mail.example.co.uk";
the name itself when it is a public suffix.
@spec size() :: pos_integer()
How many rules the list in use has.