Liking cljdoc? Tell your friends :D

inet.data.format.psl

Functions to use Mozilla Public Suffix List format files.

The supported format extends the PSL format. It has these differences:

  • Lines that begin with # are comments. Lines that begin with // are also comments.

  • A + before a domain indicates a "dynamic" rule. Dynamic rules act as normal rules unless the lookup domain is identical to the suffix domain. In this case, the lookup continues with the next matching rule.

See the tests for examples.

Functions to use Mozilla Public Suffix List format files.

The supported format extends the PSL format. It has these differences:

- Lines that begin with `#` are comments. Lines that begin with `//` are also
  comments.

- A `+` before a domain indicates a "dynamic" rule. Dynamic rules act as
  normal rules unless the lookup domain is identical to the suffix domain. In
  this case, the lookup continues with the next matching rule.

See the tests for examples.
raw docstring

*default-psl-url*clj

URL of the default Mozilla Public Suffix List file.

URL of the default Mozilla Public Suffix List file.
sourceraw docstring

*network-timeout-ms*clj

Default connection and read timeout, in milliseconds, for PSL refreshes.

Default connection and read timeout, in milliseconds, for PSL refreshes.
sourceraw docstring

loadclj

(load source)
(load source {:keys [sections] :or {sections #{:private :icann}}})

Load a Mozilla Public Suffix List format file from the Reader source.

The optional opts map has this option:

  • :sections: A set from #{:icann :private}. It selects sections of the list to include. The PSL has the // ===BEGIN ICANN DOMAINS=== and // ===BEGIN PRIVATE DOMAINS=== marker comments. Pass #{:icann} to ignore the user-contributed PRIVATE section. The default has both sections.

source must specifically be a java.io.BufferedReader, as required by line-seq. opts is normally nil or a map; non-associative values are treated like nil by map destructuring. A supplied :sections must be a set. Parsing is lenient about malformed domain rules: they become nil prefixes and remain in the returned set and rule map.

Nil source throws java.lang.NullPointerException; another Reader or non-reader throws java.lang.ClassCastException; reading failures throw java.io.IOException; and a :sections value unsupported by contains? throws java.lang.IllegalArgumentException. For n retained rules with longest encoded domain b and encoded byte total B, loading takes O(n^2 * b + B) worst-case time and O(n + B) result space.

Load a Mozilla Public Suffix List format file from the Reader `source`.

The optional `opts` map has this option:

- `:sections`: A set from `#{:icann :private}`. It selects sections of the
  list to include. The PSL has the `// ===BEGIN ICANN DOMAINS===` and
  `// ===BEGIN PRIVATE DOMAINS===` marker comments. Pass `#{:icann}` to
  ignore the user-contributed PRIVATE section. The default has both sections.

`source` must specifically be a `java.io.BufferedReader`, as required by
`line-seq`. `opts` is normally nil or a map; non-associative values are
treated like nil by map destructuring. A supplied `:sections` must be a set.
Parsing is lenient about malformed domain rules: they become nil prefixes and
remain in the returned set and rule map.

Nil `source` throws `java.lang.NullPointerException`; another Reader or
non-reader throws `java.lang.ClassCastException`; reading failures throw
`java.io.IOException`; and a `:sections` value unsupported by `contains?`
throws `java.lang.IllegalArgumentException`. For `n` retained rules with
longest encoded domain `b` and encoded byte total `B`, loading takes O(n^2 *
b + B) worst-case time and O(n + B) result space.
sourceraw docstring

lookupclj

(lookup dom)
(lookup psl dom)

Determine the E2LD of domain from the PSL in psl. Use the default PSL from *default-psl-url* if psl is not supplied. Return nil if domain does not match psl. dom accepts a string, primitive byte array, existing DNS domain, or nil. psl must be the indexed [prefixes rules] result from load. For a valid PSL this is lenient: nil and malformed supported domains return nil. Nil or a short indexed psl also returns nil. An unsupported domain type throws java.lang.IllegalArgumentException; a non-nil, non-indexed psl throws java.lang.UnsupportedOperationException.

The one-argument form uses default-load: the cached list for *default-psl-url* if one has been loaded or refreshed, otherwise the bundled snapshot loaded via bundled-psl (no network call on first use). It never throws for load failures - refresh! is the explicit, timeout-bounded way to fetch and cache a live list. For n PSL entries, k matching ancestors, and encoded domain length b, lookup is O(b * (log n + k)).

Determine the E2LD of `domain` from the PSL in `psl`. Use the default PSL
from `*default-psl-url*` if `psl` is not supplied. Return `nil` if `domain`
does not match `psl`. `dom` accepts a string, primitive byte array, existing DNS
domain, or nil. `psl` must be the indexed `[prefixes rules]` result from `load`.
For a valid PSL this is lenient: nil and malformed supported domains return nil.
Nil or a short indexed `psl` also returns nil. An unsupported domain type throws
`java.lang.IllegalArgumentException`; a non-nil, non-indexed `psl` throws
`java.lang.UnsupportedOperationException`.

The one-argument form uses `default-load`: the cached list for
`*default-psl-url*` if one has been loaded or refreshed, otherwise the bundled
snapshot loaded via `bundled-psl` (no network call on first use). It never
throws for load failures - `refresh!` is the explicit, timeout-bounded way to
fetch and cache a live list. For `n` PSL entries, `k` matching ancestors, and
encoded domain length `b`, lookup is O(b * (log n + k)).
sourceraw docstring

refresh!clj

(refresh!)
(refresh! url-or-opts)
(refresh! url {:keys [timeout-ms] :or {timeout-ms *network-timeout-ms*}})

Refresh the cached default PSL.

With no arguments, fetch *default-psl-url*. An optional map supports :timeout-ms; a URL and options map can also be supplied for testing or applications with more than one PSL. A failed refresh returns the last known-good list for that URL, or the bundled snapshot, and leaves the cache unchanged.

Refresh the cached default PSL.

With no arguments, fetch `*default-psl-url*`. An optional map supports
`:timeout-ms`; a URL and options map can also be supplied for testing or
applications with more than one PSL. A failed refresh returns the last
known-good list for that URL, or the bundled snapshot, and leaves the cache
unchanged.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close