package dns-client

  1. Overview
  2. Docs

A flow module based on non-blocking I/O on top of the Lwt_unix socket API.

type flow = Lwt_unix.file_descr

A flow is a network connection initialized by T.connect

type +'a io = 'a Lwt.t

io is the type of an effect. 'err is a polymorphic variant.

type io_addr = Lwt_unix.inet_addr * int

An address for a given flow type, usually this will consist of IP address + a TCP/IP or UDP/IP port number, but for some flow types it can carry additional information for purposes of cryptographic verification. TODO at least that would be nice in the future. TODO

type ns_addr = [ `TCP | `UDP ] * io_addr

TODO well this is kind of crude; it's a tuple to prevent having to do endless amounts of currying things when implementing flow types, and we need to know the protocol used so we can prefix packets for DNS-over-TCP and set correct socket options etc. therefore we can't just use the opaque io_addr. TODO

type stack = unit

A stack with which to connect, e.g. IPv4.tcpv4

type t

The abstract state of a DNS client.

val create : ?rng:(int -> Cstruct.t) -> ?nameserver:ns_addr -> stack -> t

create ~rng ~nameserver stack creates the state record of the DNS client.

val nameserver : t -> ns_addr

The address of a nameserver that is supposed to work with the underlying flow, can be used if the user does not want to bother with configuring their own.

val rng : t -> int -> Cstruct.t

rng t is a random number generator.

val connect : ?nameserver:ns_addr -> t -> (flow, [> `Msg of string ]) Stdlib.result io

connect addr is a new connection (flow) to addr, or an error.

val send : flow -> Cstruct.t -> (unit, [> `Msg of string ]) Stdlib.result io

send flow buffer sends buffer to the flow upstream.

val recv : flow -> (Cstruct.t, [> `Msg of string ]) Stdlib.result io

recv flow tries to read a buffer from the flow downstream.

val close : flow -> unit io

close flow closes the flow, freeing up resources.

val bind : 'a io -> ('a -> 'b io) -> 'b io

a.k.a. >>=

val lift : 'a -> 'a io
OCaml

Innovation. Community. Security.