package dns-server

  1. Overview
  2. Docs
type s

The state of a primary DNS server.

val server : s -> t

server s is the server of the primary.

val data : s -> Dns_trie.t

data s is the data store of s.

val with_data : s -> Ptime.t -> int64 -> Dns_trie.t -> s * (Ipaddr.t * string list) list

with_data s now ts trie replaces the current data with trie in s. The returned notifications should be send out.

val with_keys : s -> Ptime.t -> int64 -> ('a Domain_name.t * Dns.Dnskey.t) list -> s * (Ipaddr.t * string list) list

with_keys s now ts keys replaces the current keys with keys in s, and generates notifications.

val trie_cache : s -> trie_cache

trie_cache s is the trie cache of the server.

val create : ?keys:('a Domain_name.t * Dns.Dnskey.t) list -> ?unauthenticated_zone_transfer:bool -> ?tsig_verify:Dns.Tsig_op.verify -> ?tsig_sign:Dns.Tsig_op.sign -> rng:(int -> string) -> Dns_trie.t -> s

create ~keys ~unauthenticated_zone_transfer ~tsig_verify ~tsig_sign ~rng data creates a primary server. If unauthenticated_zone_transfer is provided and true (defaults to false), anyone can transfer the zones.

val handle_packet : ?packet_callback:packet_callback -> s -> Ptime.t -> int64 -> Dns.proto -> Ipaddr.t -> int -> Dns.Packet.t -> 'a Domain_name.t option -> s * Dns.Packet.t option * (Ipaddr.t * string list) list * [> `Notify of Dns.Soa.t option | `Keep ] option

handle_packet ~packet_callback s now ts src src_port proto key packet handles the given packet, returning new state, an answer, and potentially notify packets to secondary name servers. If packet_callback is specified, it is called for each incoming query. If it returns Some reply, this reply is used instead of the usual lookup in the zone data. It can be used for custom query processing, such as for load balancing or transporting data.

val handle_buf : ?packet_callback:packet_callback -> s -> Ptime.t -> int64 -> Dns.proto -> Ipaddr.t -> int -> string -> s * string list * (Ipaddr.t * string list) list * [ `Notify of Dns.Soa.t option | `Signed_notify of Dns.Soa.t option | `Keep ] option * [ `raw ] Domain_name.t option

handle_buf ~packet_callback s now ts proto src src_port buffer decodes the buffer, processes the DNS frame using handle_packet, and encodes the reply. The result is a new state, potentially a list of answers to the requestor, a list of notifications to send out, information whether a notify (or signed notify) was received, and the hmac key used for authentication. If packet_callback is specified, it is called for each incoming query. If it returns Some reply, this reply is used instead of the usual lookup in the zone data. This can be used for custom query processing, such as for load balancing or transporting data.

val closed : s -> Ipaddr.t -> s

closed s ip marks the connection to ip closed.

val timer : s -> Ptime.t -> int64 -> s * (Ipaddr.t * string list) list

timer s now ts may encode some notifications to secondary name servers if previous ones were not acknowledged.

val to_be_notified : s -> [ `host ] Domain_name.t -> (Ipaddr.t * [ `raw ] Domain_name.t option) list

to_be_notified s zone returns a list of pairs of IP address and optional tsig key name of the servers to be notified for a zone change. This list is based on (a) NS entries for the zone, (b) registered TSIG transfer keys, and (c) active connection (which transmitted a signed SOA).

OCaml

Innovation. Community. Security.