add crypto
[ddos.git] / dnsq.mli
blobdb17d04d98aa02da126b7a76f2e2e44b54ca86df
1 (** Simple DNS stub resolver. *)
3 (**
4 All domains must be punycoded.
5 *)
7 open Devkit
9 val verbose : int ref
11 (** Type of a DNS server result code. *)
12 type dres =
13 | DNS of Dns.rcode (** rcode of DNS query answer *)
14 | TIMEOUT (** query performed, but no answer received *)
15 | ADDR (** no query was needed, address converted from string *)
16 | INVALID (** no query was needed, domain name invalid *)
17 | BLACKDOMAIN (** no query was needed, domain name is blacklisted *)
18 | BLACKIP (** all domain ips are blacklisted *)
20 val show_dres : dres -> string
22 (** Type for the result of a DNS query. *)
23 type ttl = Forever | Seconds of int
24 type ip = { ip : Network.ipv4; ttl : ttl; }
25 type result = { domain: string; dres: dres; cname: string option; ips: ip list; txt : string list list }
27 (** Type of a handle to perform DNS queries. Contains the sockaddr where to send queries packet on, amongst other info. *)
28 type t
30 (** [upstream ?port ?edns ?timeout endpoint] creates a handle to send DNS queries to hostname [endpoint].
31 NB this function creates a socket which is never closed. I.e. call it once per upstream in the process lifetime,
32 e.g. at toplevel (as a lazy value).
33 API should be improved to allow destroying values of type [t] *)
34 val upstream : ?port:int -> ?edns:int -> ?timeout:float -> string -> t Lwt.t
36 (** [status t] display status such as the number of queries running and number of queries done for the handler [t]. *)
37 val status : t -> string
39 (** [query_exn t domain] performs a synchronous query with [t] on [domain].
40 @param qtype query type A (default) or TXT
42 val query_exn : t -> ?qtype:Dns.qtype -> string -> result
44 (** [query_exn t domain] performs an asynchronous query ([qtype] A or TXT) with [t] on [domain].
45 @param qtype query type A (default) or TXT
47 val do_query : t -> ?qtype:Dns.qtype -> string -> result Lwt.t
49 val send_query_forget : t -> ?qtype:Dns.qtype -> string -> unit Lwt.t