Functions for interacting with DNS domain names.
This namespace represents domain names internally in a normalized byte-oriented form. The normalized form has these properties:
This form has these benefits:
The main disadvantage is that this form makes it more difficult to find the immediate parent of a given domain.
Functions for interacting with DNS domain names. This namespace represents domain names internally in a normalized byte-oriented form. The normalized form has these properties: - IDN labels use IDNA encoding. - Domain labels go from top-level to bottom-level. This is the reverse of the usual order. - A byte comes before each label. The byte gives the count of bytes in the label. This form has these benefits: - It can represent any binary data accurately, the same as the DNS wire form. - Lexicographic byte order is also hierarchical order. - For a given child domain and ancestor domain, you can find the next longer child of the ancestor. The main disadvantage is that this form makes it more difficult to find the immediate parent of a given domain.
(->domain dom)Coerce dom to a DNSDomain. Accepted values are strings, primitive byte
arrays, or existing DNS domains. This is strict and throws
inet.data.dns.DNSDomainException for malformed, unsupported, or nil input.
Parsing is O(b) in input length.
Coerce `dom` to a DNSDomain. Accepted values are strings, primitive byte arrays, or existing DNS domains. This is strict and throws `inet.data.dns.DNSDomainException` for malformed, unsupported, or nil input. Parsing is O(b) in input length.
(->domain-set coll)Create a hierarchical set from the domains in finite seqable coll, or an
empty set when coll is nil. Members may be strings, primitive byte arrays,
existing DNS domains, or nil. This constructor is lenient for malformed
supported members: domain converts them to nil, which the set retains as
the root representation. An unsupported member or non-seqable coll throws
java.lang.IllegalArgumentException. Building n members takes O(n^2 * b +
B) worst-case time and O(n + B) space, where b is the longest encoded
domain and B is the encoded byte total.
Create a hierarchical set from the domains in finite seqable `coll`, or an empty set when `coll` is nil. Members may be strings, primitive byte arrays, existing DNS domains, or nil. This constructor is lenient for malformed supported members: `domain` converts them to nil, which the set retains as the root representation. An unsupported member or non-seqable `coll` throws `java.lang.IllegalArgumentException`. Building `n` members takes O(n^2 * b + B) worst-case time and O(n + B) space, where `b` is the longest encoded domain and `B` is the encoded byte total.
(ascii->idn name)Convert an ASCII internationalized domain name to Unicode using Java's IDNA2003 implementation. This does not implement IDNA2008 or UTS #46.
Convert an ASCII internationalized domain name to Unicode using Java's IDNA2003 implementation. This does not implement IDNA2008 or UTS #46.
(domain dom)Return the DNS domain for representation dom. Accepted values are
strings, primitive byte arrays, existing DNS domains, and nil, which is the
root-domain representation. This is lenient for supported types: malformed
input returns nil. An unsupported type throws java.lang.IllegalArgumentException.
Parsing is O(b) in input length.
Return the DNS domain for representation `dom`. Accepted values are strings, primitive byte arrays, existing DNS domains, and nil, which is the root-domain representation. This is lenient for supported types: malformed input returns nil. An unsupported type throws `java.lang.IllegalArgumentException`. Parsing is O(b) in input length.
(domain-ancestors child)(domain-ancestors child parent)Generate a seq of all the domains for which the domain child is a proper
subdomain. The seq starts with the domain after parent and ends with the
domain itself. Uses the implied empty root domain as parent if you do not
supply one. Arguments accept strings, byte arrays, or existing DNS domains.
This is strict and throws inet.data.dns.DNSDomainException for invalid input.
For k returned ancestors and encoded length b, realization is O(k * b) time
and O(1) additional space per realized step.
Generate a seq of all the domains for which the domain `child` is a proper subdomain. The seq starts with the domain after `parent` and ends with the domain itself. Uses the implied empty root domain as `parent` if you do not supply one. Arguments accept strings, byte arrays, or existing DNS domains. This is strict and throws `inet.data.dns.DNSDomainException` for invalid input. For `k` returned ancestors and encoded length `b`, realization is O(k * b) time and O(1) additional space per realized step.
(domain-byte-seq dom)Return the internal normalized byte form of the domain dom as a sequence
of bytes. dom accepts a string, primitive byte array, existing DNS domain,
or nil (the empty root representation). This low-level function is lenient
and does not validate strings or arrays; malformed supported values can yield
an empty or invalid byte sequence. An unsupported type strictly throws
java.lang.IllegalArgumentException. Realizing b bytes takes O(b) time and
O(b) worst-case additional space when a string must be encoded.
Return the internal normalized byte form of the domain `dom` as a sequence of bytes. `dom` accepts a string, primitive byte array, existing DNS domain, or `nil` (the empty root representation). This low-level function is lenient and does not validate strings or arrays; malformed supported values can yield an empty or invalid byte sequence. An unsupported type strictly throws `java.lang.IllegalArgumentException`. Realizing `b` bytes takes O(b) time and O(b) worst-case additional space when a string must be encoded.
(domain-compare left right)(domain-compare stable left right)Compare two domains. The result semantics are the same as compare. When
stable is true (the default), the result is 0 only when the domains are
value-identical. When stable is false, the result is 0 when the domains are
identical up to their minimum common full-label length. Domain comparison
always ignores case. Domain arguments accept strings, primitive byte arrays, or
existing DNS domains; stable must be Boolean. This is strict: an invalid
domain throws inet.data.dns.DNSDomainException; a non-Boolean stable throws
java.lang.ClassCastException, and nil stable throws
java.lang.NullPointerException. Comparison is O(b) in normalized domain
length.
Compare two domains. The result semantics are the same as `compare`. When `stable` is true (the default), the result is 0 only when the domains are value-identical. When `stable` is false, the result is 0 when the domains are identical up to their minimum common full-label length. Domain comparison always ignores case. Domain arguments accept strings, primitive byte arrays, or existing DNS domains; `stable` must be Boolean. This is strict: an invalid domain throws `inet.data.dns.DNSDomainException`; a non-Boolean `stable` throws `java.lang.ClassCastException`, and nil `stable` throws `java.lang.NullPointerException`. Comparison is O(b) in normalized domain length.
(domain-contains? parent child)Determine if the domain child is a subdomain of or identical to the domain
parent. Both arguments accept strings, primitive byte arrays, or existing DNS domain
values. This is strict and throws inet.data.dns.DNSDomainException for
malformed or unsupported input. Comparison is O(b), where b is the longer
normalized domain length.
Determine if the domain `child` is a subdomain of or identical to the domain `parent`. Both arguments accept strings, primitive byte arrays, or existing DNS domain values. This is strict and throws `inet.data.dns.DNSDomainException` for malformed or unsupported input. Comparison is O(b), where `b` is the longer normalized domain length.
(domain-hostname? dom)(domain-hostname? dom underscores)Determine if the domain dom is a valid hostname. Let hostnames contain
underscores if underscores is true (default false). dom must be a string,
primitive byte array, existing DNS domain, or nil root representation;
underscores must be Boolean. This is lenient and returns false for invalid
hostname content. An unsupported dom throws java.lang.IllegalArgumentException;
a non-Boolean flag throws java.lang.ClassCastException, and a nil flag throws
java.lang.NullPointerException. Validation is O(b) in encoded length.
Determine if the domain `dom` is a valid hostname. Let hostnames contain underscores if `underscores` is true (default false). `dom` must be a string, primitive byte array, existing DNS domain, or nil root representation; `underscores` must be Boolean. This is lenient and returns `false` for invalid hostname content. An unsupported `dom` throws `java.lang.IllegalArgumentException`; a non-Boolean flag throws `java.lang.ClassCastException`, and a nil flag throws `java.lang.NullPointerException`. Validation is O(b) in encoded length.
(domain-labels dom)Return a sequence of labels in the domain dom. dom accepts strings, byte
arrays, existing DNS domains, or nil. Like domain-byte-seq, this is lenient
and does not validate supported values; malformed input can produce an empty or
invalid label sequence, and a byte array with a negative label length can fail
to terminate. An unsupported type throws
java.lang.IllegalArgumentException. Realization is O(b) time and O(b) space,
where b is encoded length.
Return a sequence of labels in the domain `dom`. `dom` accepts strings, byte arrays, existing DNS domains, or nil. Like `domain-byte-seq`, this is lenient and does not validate supported values; malformed input can produce an empty or invalid label sequence, and a byte array with a negative label length can fail to terminate. An unsupported type throws `java.lang.IllegalArgumentException`. Realization is O(b) time and O(b) space, where `b` is encoded length.
(domain-next child)(domain-next child parent)For the domain child which is a subdomain of the domain parent, return
the immediate child domain of parent. This domain is identical to child,
or it is a parent domain of child. Returns nil if there is no such domain.
Uses the implied empty root domain as parent if you do not supply one.
Arguments accept strings, byte arrays, or existing DNS domains. This is strict
and throws inet.data.dns.DNSDomainException for invalid input. It returns
nil when parent is not an ancestor. The operation is O(b) in encoded
length.
For the domain `child` which is a subdomain of the domain `parent`, return the immediate child domain of `parent`. This domain is identical to `child`, or it is a parent domain of `child`. Returns `nil` if there is no such domain. Uses the implied empty root domain as `parent` if you do not supply one. Arguments accept strings, byte arrays, or existing DNS domains. This is strict and throws `inet.data.dns.DNSDomainException` for invalid input. It returns `nil` when `parent` is not an ancestor. The operation is O(b) in encoded length.
(domain-parent dom)Return the domain of which dom is an immediate subdomain. dom accepts
strings, byte arrays, or an existing DNS domain. This is strict and throws
inet.data.dns.DNSDomainException for malformed or unsupported input; the root
domain has no parent and returns nil. The scan is O(b) in normalized byte
length.
Return the domain of which `dom` is an immediate subdomain. `dom` accepts strings, byte arrays, or an existing DNS domain. This is strict and throws `inet.data.dns.DNSDomainException` for malformed or unsupported input; the root domain has no parent and returns `nil`. The scan is O(b) in normalized byte length.
(domain-set & doms)Create a hierarchical set from variadic domains doms; each member accepts
the same types as domain. This is lenient for malformed supported members,
which become retained nil root representations. An unsupported member throws
java.lang.IllegalArgumentException. Building n members takes O(n^2 * b +
B) worst-case time and O(n + B) space, where b is the longest encoded
domain and B is the encoded byte total.
Create a hierarchical set from variadic domains `doms`; each member accepts the same types as `domain`. This is lenient for malformed supported members, which become retained nil root representations. An unsupported member throws `java.lang.IllegalArgumentException`. Building `n` members takes O(n^2 * b + B) worst-case time and O(n + B) space, where `b` is the longest encoded domain and `B` is the encoded byte total.
(domain-subdomain? parent child)Determine if child is a proper subdomain of parent. Both arguments
accept strings, byte arrays, or existing DNS domain values. This is strict and
throws inet.data.dns.DNSDomainException for malformed or unsupported input.
Comparison is O(b), where b is the longer normalized domain length.
Determine if `child` is a proper subdomain of `parent`. Both arguments accept strings, byte arrays, or existing DNS domain values. This is strict and throws `inet.data.dns.DNSDomainException` for malformed or unsupported input. Comparison is O(b), where `b` is the longer normalized domain length.
(domain? dom)Determine if dom represents a DNS domain. It accepts strings, byte arrays,
existing DNS domains, and nil; nil denotes the root and returns true.
This is lenient and returns false for malformed or unsupported non-nil
input. Validation is O(b) in the encoded domain length.
Determine if `dom` represents a DNS domain. It accepts strings, byte arrays, existing DNS domains, and `nil`; `nil` denotes the root and returns `true`. This is lenient and returns `false` for malformed or unsupported non-nil input. Validation is O(b) in the encoded domain length.
(idn->ascii name)Convert an internationalized domain name to ASCII using Java's IDNA2003 implementation. This does not implement IDNA2008 or UTS #46.
Convert an internationalized domain name to ASCII using Java's IDNA2003 implementation. This does not implement IDNA2008 or UTS #46.
(idn-str dom)Convert dom to IDN string form and interpret Punycode. dom accepts
strings, primitive byte arrays, existing DNS domains, or nil. This is lenient
for malformed supported input and can return an empty or partially decoded
string; a byte array with a negative label length can fail to terminate. An
unsupported type throws java.lang.IllegalArgumentException. For structurally
valid input, conversion is O(b) in normalized byte length.
Convert `dom` to IDN string form and interpret Punycode. `dom` accepts strings, primitive byte arrays, existing DNS domains, or nil. This is lenient for malformed supported input and can return an empty or partially decoded string; a byte array with a negative label length can fail to terminate. An unsupported type throws `java.lang.IllegalArgumentException`. For structurally valid input, conversion is O(b) in normalized byte length.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |