Module Resolver_mirage.Make

Provides a DNS-enabled Resolver_lwt given a network stack.

Parameters

module R : Mirage_crypto_rng_mirage.S
module T : Mirage_time.S
module C : Mirage_clock.MCLOCK
module P : Mirage_clock.PCLOCK
module S : Tcpip.Stack.V4V6

Signature

include S
include Resolver_lwt.S
type 'a io = 'a Lwt.t

Abstract type of the cooperative threading library used, normally defined via the IO module type

type t

State handle for a running resolver

include Sexplib0.Sexpable.S with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
type svc = Resolver.service

Abstract type for a service entry, which maps a URI scheme into a protocol handler and TCP port

val sexp_of_svc : svc -> Sexplib0.Sexp.t
val svc_of_sexp : Sexplib0.Sexp.t -> svc
type rewrite_fn = svc -> Uri.t -> Conduit.endp io

A rewrite function resolves a service and a URI into a concrete endpoint.

type service_fn = string -> svc option io

A service function maps the string (such as http or ftp) from a URI scheme into a service description that includes enough metadata about the service to subsequently resolve it into an endpoint.

f ++ g is the composition of the service functions f and g.

val init : ?service:service_fn -> ?rewrites:(string * rewrite_fn) list -> unit -> t

init ?service ?rewrites will initialize the resolver and return a state handler. The service argument should contain the system-specific resolution mechanism for URI schemas.

The rewrites argument can optionally override a subset of the URI domain name with the given rewrite_fn to permit custom resolution rules. For example, a rewrite rule for ".xen" would let the rewrite function resolve hostnames such as "foo.xen" into a shared memory channel for the "foo" virtual machine.

val add_rewrite : host:string -> f:rewrite_fn -> t -> unit

add_rewrite ~host f t will add to the t resolver the f rewrite rule for all the domain names that shortest-prefix match host

val set_service : f:service_fn -> t -> unit
val service : t -> service_fn

service t is the function which is called when trying to resolve a hostname with t.

val resolve_uri : ?rewrites:(string * rewrite_fn) list -> uri:Uri.t -> t -> Conduit.endp io

resolve_uri ?rewrites ~uri t will use t to resolve the uri into a concrete endpoint. Any rewrites that are passed in will be overlayed on the existing rules within the t resolver, but not otherwise modify it.

val static : (string, port:int -> Conduit.endp) Stdlib.Hashtbl.t -> t

static hosts constructs a resolver that looks up any resolution requests from the static hosts hashtable instead of using the system resolver.

val localhost : t

localhost is a static resolver that has a single entry that maps localhost to 127.0.0.1, and fails on all other hostnames.

val v : ?nameservers:string list -> S.t -> (t, [> `Msg of string ]) Stdlib.result Lwt.t

v ~nameservers stack () TODO. An error is returned if any of the nameserver specifications do not parse.