Dns_serverThe main purpose of this module is to provide an implementation of a standard DNS server based on Dns.Query and Dns.Loader.
For a basic DNS server, call process_of_zonebuf, pass the result to processor_of_process, and then invoke the resulting processor function for each received packet.
This module also provides a way to override the parsing and marshaling of DNS packets to allow extensions of DNS to be implemented, such as DNSCurve.
A tuple consisting of an IPv4 or IPv6 address and a TCP or UDP port number.
type 'a process =
src:ip_endpoint ->
dst:ip_endpoint ->
'a ->
Dns.Query.answer option Lwt.tA type of function that takes an abstract request plus source and destination endpoint addresses, and asynchronously produces an answer to the request, or None if no answer is possible. For most applications the type 'a will be Dns.Packet.t, but may be different if a custom parsing/marshalling layer is required.
module type PROCESSOR = sig ... endThis type of module provides functions for parsing, marshalling and processing DNS requests to produce answers.
val compose :
Dns.Packet.t process ->
Dns.Packet.t process ->
Dns.Packet.t processcompose process backup_process is process unless it returns an rcode other than NoError in which case it becomes backup_process.
val process_query :
?alloc:(unit -> Cstruct.t) ->
Cstruct.t ->
int ->
ip_endpoint ->
ip_endpoint ->
(module PROCESSOR) ->
Cstruct.t option Lwt.tprocess_query ?alloc ibuf ibuflen src dst processor
val processor_of_process : Dns.Packet.t process -> Dns.Packet.t processorReturns a packet processor module by combining Dns.Protocol.Server with the specified packet processing function.
val process_of_zonebufs : string list -> Dns.Packet.t processGiven a list of DNS zone files as strings, parses them using Dns.Loader and returns a processing function that answers requests through the use of Dns.Query.
val process_of_zonebuf : string -> Dns.Packet.t processThis is a convenience function that is equivalent to calling process_of_zonebufs with a list containing a single zone file string.