Page
Library
Module
Module type
Parameter
Class
Class type
Source
Dns_trieSourcePrefix tree data structure for domain names
The key is a Domain_name, whereas the value may be any resource record. The representation is a tree, where the edges are domain name labels, and the nodes carry a resource map. Some special treatment is applied for zones, which must have a start of authority entry and a set of name servers. End of authority, also known as delegation, is supported. Aliases (canonical names, CNAME records) are also supported.
The data structure tries to preserve invariants recommended by the domain name system, such as that for any name there may either be an alias or any other record, there must be a SOA record, and multiple NS records for an authoritative zone, a resource type must have entries of the given type (no NS record for A type, the ttl for all resource records of a rrset is the same.
The type of the trie.
insert_map m t inserts all elements of the domain name map m into t, potentially existing are unioned with Dns.Rr_map.unionee.
replace_map m t replaces in the trie t all existing bindings of the domain name map m with the provided map.
remove_map m t removes all elements of the domain name map m from t.
insert n k v t inserts k, v under n in t. Existing entries are unioneed with Dns.Rr_map.union_rr.
replace n k v t inserts k, v under n in t. Existing entries are replaced.
remove k ty v t removes ty, v from t at k. Beware, this may lead to a t where the initially mentioned invariants are violated.
remove_ty k ty t removes ty from t at k. Beware, this may lead to a t where the initially mentioned invariants are violated.
remove_all k t removes all entries of k in t. Beware, this may lead to a t where the initially mentioned invariants are violated.
remove_zone name t remove the zone name from t, retaining subzones (entries with Soa records). This removes as well any delegations.
type zone_check = [ | `Missing_soa of [ `raw ] Domain_name.t| `Cname_other of [ `raw ] Domain_name.t| `Bad_ttl of [ `raw ] Domain_name.t * Dns.Rr_map.b| `Empty of [ `raw ] Domain_name.t * Dns.Rr_map.k| `Missing_address of [ `host ] Domain_name.t| `Soa_not_a_host of [ `raw ] Domain_name.t * string ]pp_err ppf err pretty prints the error err.
check t checks all invariants.
type e = [ | `Delegation of [ `raw ] Domain_name.t * (int32 * Domain_name.Host_set.t)| `EmptyNonTerminal of [ `raw ] Domain_name.t * Dns.Soa.t| `NotAuthoritative| `NotFound of [ `raw ] Domain_name.t * Dns.Soa.t ]The type of lookup errors.
zone k t returns either the zone and soa for k in t, or an error.
val lookup_with_cname :
'a Domain_name.t ->
'b Dns.Rr_map.key ->
t ->
(Dns.Rr_map.b * ([ `raw ] Domain_name.t * int32 * Domain_name.Host_set.t), e)
resultlookup_with_cname k ty t finds k, ty in t. It either returns the found resource record set and authority information, a cname alias and authority information, or an error.
lookup k ty t finds k, ty in t, which may lead to an error.
val lookup_any :
'a Domain_name.t ->
t ->
(Dns.Rr_map.t * ([ `raw ] Domain_name.t * int32 * Domain_name.Host_set.t), e)
resultlookup_any k t looks up all resource records of k in t, and returns that and the authority information.
val lookup_glue :
'a Domain_name.t ->
t ->
(int32 * Ipaddr.V4.Set.t) option * (int32 * Ipaddr.V6.Set.t) optionlookup_glue k t finds glue records (A, AAAA) for k in t. It ignores potential DNS invariants, e.g. that there is no surrounding zone.
entries name t returns either the SOA and all entries for the requested name, or an error.
fold key t f acc calls f with dname value acc element in t.
val diff :
'a Domain_name.t ->
Dns.Soa.t ->
old:t ->
t ->
(Dns.Soa.t
* [ `Empty
| `Full of Dns.Name_rr_map.t
| `Difference of Dns.Soa.t * Dns.Name_rr_map.t * Dns.Name_rr_map.t ],
[> `Msg of string ])
resultdiff zone soa ~old trie computes the difference of zone in old and trie, and returns either `Empty if soa is equal or newer than the one in trie, `Full (the same as entries) if zone is not present in old, or `Difference (old_soa, deleted, added). Best used with IXFR. An error occurs if zone is not present in trie.