package dns-server

  1. Overview
  2. Docs

DNS Server implementation

module Authentication : sig ... end

Authentication, stored in a Dns_trie with privileges to operations embedded in the name.

type t = private {
  1. data : Dns_trie.t;
  2. auth : Authentication.t;
  3. unauthenticated_zone_transfer : bool;
  4. rng : int -> string;
  5. tsig_verify : Dns.Tsig_op.verify;
  6. tsig_sign : Dns.Tsig_op.sign;
}

The state of a DNS server.

val create : ?unauthenticated_zone_transfer:bool -> ?tsig_verify:Dns.Tsig_op.verify -> ?tsig_sign:Dns.Tsig_op.sign -> ?auth:Authentication.t -> Dns_trie.t -> (int -> string) -> t

create ~unauthenticated_zone_transfer ~tsig_verify ~tsig_sign ~auth data rng constructs a t. See Primary.create and Secondary.create for the logic running a primary or secondary server.

val with_data : t -> Dns_trie.t -> t

with_data t data is t' where the data field is updated with the provided value. Be aware that this function breaks the semantics of a primary server with secondaries, since secondaries won't be notified and will be out of sync. Use if you know what you do. The data of a secondary will usually come via zone transfer from the primary name services.

val text : 'a Domain_name.t -> Dns_trie.t -> (string, [> `Msg of string ]) result

text name trie results in a string representation (zonefile) of the trie.

handle_question t question handles the DNS query question by looking it up in the trie of t. The result is either an answer or an error.

update_data data domain update_content applies the update_content to the data for domain. This function breaks the semantics of a primary server with secondaries, since the secondaries won't be notified of the update and will be out of sync. Use if you know what you are doing.

val handle_update : t -> Dns.proto -> [ `raw ] Domain_name.t option -> Dns.Packet.Question.t -> Dns.Packet.Update.t -> (Dns_trie.t * ([ `raw ] Domain_name.t * Dns.Soa.t) list, Dns.Rcode.t) result

handle_update t proto keyname question update authenticates the update request and processes the update. This function breaks the semantics of a primary server with secondaries, since the secondaries won't be notified. Use if you know what you are doing.

val handle_axfr_request : t -> Dns.proto -> [ `raw ] Domain_name.t option -> Dns.Packet.Question.t -> (Dns.Packet.Axfr.t, Dns.Rcode.t) result

handle_axfr_request t proto keyname question authenticates the zone transfer request and processes it. If the request is valid, and the zone available, a zone transfer is returned.

type trie_cache
val handle_ixfr_request : t -> trie_cache -> Dns.proto -> [ `raw ] Domain_name.t option -> Dns.Packet.Question.t -> Dns.Soa.t -> (Dns.Packet.Ixfr.t, Dns.Rcode.t) result

handle_ixfr_request t cache proto keyname question soa authenticates the incremental zone transfer request and processes it. If valid, an incremental zone transfer is returned.

val handle_tsig : ?mac:string -> t -> Ptime.t -> Dns.Packet.t -> string -> (([ `raw ] Domain_name.t * Dns.Tsig.t * string * Dns.Dnskey.t) option, Dns.Tsig_op.e * string option) result

handle_tsig ~mac t now packet buffer verifies the tsig signature if present, returning the keyname, tsig, mac, and used key.

type packet_callback = Dns.Packet.Question.t -> Dns.Packet.reply option

packet_callback question either returns a reply to a DNS question Some reply or None.

module Primary : sig ... end
module Secondary : sig ... end
OCaml

Innovation. Community. Security.