package dns-client

  1. Overview
  2. Docs

Parameters

module T : S

Signature

type t
val create : ?size:int -> ?edns:[ `None | `Auto | `Manual of Dns.Edns.t ] -> ?nameservers:(Dns.proto * T.io_addr list) -> ?timeout:int64 -> T.stack -> t

create ~size ~edns ~nameservers ~timeout stack creates the state of the DNS client. We use timeout (ns, default 5s) as a time budget for connect and request timeouts. To specify a timeout, use create ~timeout:(Duration.of_sec 3). Whether or not to use EDNS in queries is controlled by ~edns (defaults to `None): if None, no EDNS will be present, `Auto adds TCP Keepalive if protocol is TCP, `Manual edns adds the EDNS data specified.

val nameservers : t -> Dns.proto * T.io_addr list

nameservers state returns the list of nameservers to be used.

val getaddrinfo : t -> 'response Dns.Rr_map.key -> 'a Domain_name.t -> ('response, [> `Msg of string ]) result T.io

getaddrinfo state query_type name is the query_type-dependent response regarding name, or an Error _ message. See Dns_client.query_state for more information about the result types.

val gethostbyname : t -> [ `host ] Domain_name.t -> (Ipaddr.V4.t, [> `Msg of string ]) result T.io

gethostbyname state hostname is the IPv4 address of hostname resolved via the state specified. If the query fails, or if the domain does not have any IPv4 addresses, an Error _ message is returned. Any extraneous IPv4 addresses are ignored. For an example of using this API, see unix/ohost.ml in the distribution of this package.

val gethostbyname6 : t -> [ `host ] Domain_name.t -> (Ipaddr.V6.t, [> `Msg of string ]) result T.io

gethostbyname6 state hostname is the IPv6 address of hostname resolved via the state specified.

It is the IPv6 equivalent of gethostbyname.

val get_resource_record : t -> 'response Dns.Rr_map.key -> 'a Domain_name.t -> ('response, [> `Msg of string | `No_data of [ `raw ] Domain_name.t * Dns.Soa.t | `No_domain of [ `raw ] Domain_name.t * Dns.Soa.t ]) result T.io

get_resource_record state query_type name resolves query_type, name via the state specified. The behaviour is equivalent to getaddrinfo, apart from the error return value - get_resource_record distinguishes some errors, at the moment No_data if the name exists, but not the query_type, and No_domain if the name does not exist. This allows clients to treat these error conditions explicitly.

OCaml

Innovation. Community. Security.