diff --git a/.travis-ci.sh b/.travis-ci.sh index 3d77ed9a6..6bde7b1a3 100755 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -1,5 +1,3 @@ -OPAM_DEPENDS="lwt cstruct ipaddr re ounit cmdliner io-page sexplib" - case "$OCAML_VERSION,$OPAM_VERSION" in 3.12.1,1.0.0) ppa=avsm/ocaml312+opam10 ;; 3.12.1,1.1.0) ppa=avsm/ocaml312+opam11 ;; @@ -15,14 +13,25 @@ sudo apt-get update -qq sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra opam export OPAMYES=1 +export OPAMVERBOSE=1 echo OCaml version ocaml -version echo OPAM versions opam --version opam --git-version -opam init -opam install ${OPAM_DEPENDS} +opam init git://github.com/ocaml/opam-repository >/dev/null 2>&1 +opam pin dns . +opam install base64 # can remove with opam 1.2? +opam install dns eval `opam config env` +make clean make + +opam install mirage crunch +git clone git://github.com/mirage/mirage-skeleton +cd mirage-skeleton +make dns-configure +make dns-depend +make dns-build diff --git a/CHANGES b/CHANGES index bf3db8498..4a3541c26 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,17 @@ +0.10.0 (2014-08-20): +* Add `Dns_resolver_mirage` module for making stub resolution requests + using the Mirage module types. +* `Dns.Resolvconf` parses `/etc/resolv.conf` entries using `Ipaddr.t` + instead of `string` values now. +* Adapt `Dns_resolver` and `Dns_resolver_unix` to use `Ipaddr.t` more. +* Improve `mldig` to use `Ipaddr` more and add more RR printing to + match the conventional `dig` tool behaviour. +* Expose `Dns.Packet.Not_implemented` exception rather than a pattern + match failure. +* Depend on external `Base64` package instead of bundling one inside + the `Dns` packed module. +* Add a local `opam` file for easier pinning. + 0.9.1 (2014-07-29): * Fix file descriptor leak in resolver (#15, #16) by expanding `commfn` with a cleanup function. diff --git a/Makefile b/Makefile index ff42a841e..8a2c2c495 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,8 @@ PREFIX ?= /usr/local NAME=dns LWT ?= $(shell if ocamlfind query lwt.unix >/dev/null 2>&1; then echo --enable-lwt; fi) -MIRAGE ?= $(shell if ocamlfind query mirage-net >/dev/null 2>&1; then echo --enable-mirage; fi) -ifneq ($(MIRAGE_OS),xen) +MIRAGE ?= $(shell if ocamlfind query mirage >/dev/null 2>&1; then echo --enable-mirage; fi) TESTS ?= --enable-tests -endif -include Makefile.config diff --git a/_oasis b/_oasis index d48088843..f4d2f5b34 100644 --- a/_oasis +++ b/_oasis @@ -1,7 +1,7 @@ OASISFormat: 0.3 OCamlVersion: >= 4.00.0 Name: dns -Version: 0.9.1 +Version: 0.10.0 Authors: Anil Madhavapeddy, Tim Deegan, Richard Mortier, Haris Rotsos, David Sheets, Thomas Gazagnaire Maintainers: Anil Madhavapeddy License: ISC @@ -21,15 +21,19 @@ Flag nettests Description: run the internet-using tests Default: false +Flag mirage + Description: build the Mirage library + Default: false + Library dns Path: lib Findlibname: dns Pack: true Modules: - Base64, Hashcons, Loader, Name, Operators, Packet, Query, RR, Trie, + Hashcons, Loader, Name, Operators, Packet, Query, RR, Trie, Zone, Zone_lexer, Zone_parser, Resolvconf, Buf, Protocol - BuildDepends: cstruct (>= 0.7.1), cstruct.syntax, re, re.str, ipaddr (>= 2.2.0), io-page - XMetaRequires: cstruct, re, re.str, ipaddr, io-page + BuildDepends: cstruct (>= 0.7.1), cstruct.syntax, re, re.str, ipaddr (>= 2.2.0), io-page, base64 + XMetaRequires: cstruct, re, re.str, ipaddr, io-page, base64 Library "dns-lwt" Path: lwt @@ -41,6 +45,16 @@ Library "dns-lwt" XMetaRequires: lwt.unix, cstruct.lwt, dns, dns.lwt-core, ipaddr.unix, io-page.unix FindlibParent: dns +Library "dns-lwt-mirage" + Path: mirage + Build$: flag(mirage) + Install$: flag(mirage) + Findlibname: mirage + Modules: Dns_resolver_mirage + BuildDepends: cstruct, lwt.syntax, dns, dns.lwt-core, tcpip + XMetaRequires: cstruct, dns, dns.lwt-core, tcpip + FindlibParent: dns + Library "dns-lwt-core" Path: lwt Build$: flag(lwt) @@ -48,6 +62,7 @@ Library "dns-lwt-core" Findlibname: lwt-core Modules: Dns_server, Dns_resolver BuildDepends: lwt, cstruct, lwt.syntax, dns + XMetaRequires: lwt, cstruct, dns FindlibParent: dns Document dns @@ -68,7 +83,7 @@ Document dns_lwt XOCamlbuildModules: Dns_resolver, Dns_server Executable lwt_server - Path: lib_test + Path: lib_test/unix MainIs: lwt_server.ml Build$: flag(tests) && flag(lwt) Custom: true @@ -77,7 +92,7 @@ Executable lwt_server BuildDepends: lwt, lwt.unix, re, re.str, dns, dns.lwt Executable time_server - Path: lib_test + Path: lib_test/unix MainIs: time_server.ml Build$: flag(tests) && flag(lwt) Custom: true @@ -97,4 +112,4 @@ Executable mldig Test lwt_server Run$: flag(tests) && flag(lwt) Command: $lwt_server - WorkingDirectory: lib_test + WorkingDirectory: lib_test/unix diff --git a/_tags b/_tags index 78de4ee54..0fc86e355 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 78990316922073e9f73a863c21eff3b9) +# DO NOT EDIT (digest: 1fef36b7982b7347691d423e55c4d237) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -15,7 +15,6 @@ "_darcs": not_hygienic # Library dns "lib/dns.cmxs": use_dns -"lib/base64.cmx": for-pack(Dns) "lib/hashcons.cmx": for-pack(Dns) "lib/loader.cmx": for-pack(Dns) "lib/name.cmx": for-pack(Dns) @@ -30,6 +29,7 @@ "lib/resolvconf.cmx": for-pack(Dns) "lib/buf.cmx": for-pack(Dns) "lib/protocol.cmx": for-pack(Dns) +: package(base64) : package(cstruct) : package(cstruct.syntax) : package(io-page) @@ -38,58 +38,76 @@ : package(re.str) # Library dns-lwt-core "lwt/dns-lwt-core.cmxs": use_dns-lwt-core +# Library dns-lwt-mirage +"mirage/dns-lwt-mirage.cmxs": use_dns-lwt-mirage +: package(base64) +: package(cstruct) +: package(cstruct.syntax) +: package(io-page) +: package(ipaddr) +: package(lwt) +: package(lwt.syntax) +: package(re) +: package(re.str) +: package(tcpip) +: use_dns +: use_dns-lwt-core # Library dns-lwt "lwt/dns-lwt.cmxs": use_dns-lwt # Executable lwt_server -: package(cstruct) -: package(cstruct.lwt) -: package(cstruct.syntax) -: package(io-page) -: package(io-page.unix) -: package(ipaddr) -: package(ipaddr.unix) -: package(lwt) -: package(lwt.syntax) -: package(lwt.unix) -: package(re) -: package(re.str) -: use_dns -: use_dns-lwt -: use_dns-lwt-core -: custom +: package(base64) +: package(cstruct) +: package(cstruct.lwt) +: package(cstruct.syntax) +: package(io-page) +: package(io-page.unix) +: package(ipaddr) +: package(ipaddr.unix) +: package(lwt) +: package(lwt.syntax) +: package(lwt.unix) +: package(re) +: package(re.str) +: use_dns +: use_dns-lwt +: use_dns-lwt-core +: custom # Executable time_server -: package(cstruct) -: package(cstruct.lwt) -: package(cstruct.syntax) -: package(io-page) -: package(io-page.unix) -: package(ipaddr) -: package(ipaddr.unix) -: package(lwt) -: package(lwt.syntax) -: package(lwt.unix) -: package(re) -: package(re.str) -: use_dns -: use_dns-lwt -: use_dns-lwt-core -: package(cstruct) -: package(cstruct.lwt) -: package(cstruct.syntax) -: package(io-page) -: package(io-page.unix) -: package(ipaddr) -: package(ipaddr.unix) -: package(lwt) -: package(lwt.syntax) -: package(lwt.unix) -: package(re) -: package(re.str) -: use_dns -: use_dns-lwt -: use_dns-lwt-core -: custom +: package(base64) +: package(cstruct) +: package(cstruct.lwt) +: package(cstruct.syntax) +: package(io-page) +: package(io-page.unix) +: package(ipaddr) +: package(ipaddr.unix) +: package(lwt) +: package(lwt.syntax) +: package(lwt.unix) +: package(re) +: package(re.str) +: use_dns +: use_dns-lwt +: use_dns-lwt-core +: package(base64) +: package(cstruct) +: package(cstruct.lwt) +: package(cstruct.syntax) +: package(io-page) +: package(io-page.unix) +: package(ipaddr) +: package(ipaddr.unix) +: package(lwt) +: package(lwt.syntax) +: package(lwt.unix) +: package(re) +: package(re.str) +: use_dns +: use_dns-lwt +: use_dns-lwt-core +: custom # Executable mldig +: package(base64) : package(cmdliner) : package(cstruct) : package(cstruct.lwt) @@ -106,6 +124,7 @@ : use_dns : use_dns-lwt : use_dns-lwt-core +: package(base64) : package(cmdliner) : package(cstruct) : package(cstruct.lwt) diff --git a/lib/META b/lib/META index 510fcab4f..4d287e6fa 100644 --- a/lib/META +++ b/lib/META @@ -1,17 +1,28 @@ # OASIS_START -# DO NOT EDIT (digest: c262d26c5dc803b940e7a415fd29bdcd) -version = "0.9.1" +# DO NOT EDIT (digest: 08bd769e2c3d4771dc74405b93faba62) +version = "0.10.0" description = "DNS client and server implementation" -requires = "cstruct re re.str ipaddr io-page" +requires = "cstruct re re.str ipaddr io-page base64" archive(byte) = "dns.cma" archive(byte, plugin) = "dns.cma" archive(native) = "dns.cmxa" archive(native, plugin) = "dns.cmxs" exists_if = "dns.cma" +package "mirage" ( + version = "0.10.0" + description = "DNS client and server implementation" + requires = "cstruct dns dns.lwt-core tcpip" + archive(byte) = "dns-lwt-mirage.cma" + archive(byte, plugin) = "dns-lwt-mirage.cma" + archive(native) = "dns-lwt-mirage.cmxa" + archive(native, plugin) = "dns-lwt-mirage.cmxs" + exists_if = "dns-lwt-mirage.cma" +) + package "lwt-core" ( - version = "0.9.1" + version = "0.10.0" description = "DNS client and server implementation" - requires = "lwt cstruct lwt.syntax dns" + requires = "lwt cstruct dns" archive(byte) = "dns-lwt-core.cma" archive(byte, plugin) = "dns-lwt-core.cma" archive(native) = "dns-lwt-core.cmxa" @@ -20,7 +31,7 @@ package "lwt-core" ( ) package "lwt" ( - version = "0.9.1" + version = "0.10.0" description = "DNS client and server implementation" requires = "lwt.unix cstruct.lwt dns dns.lwt-core ipaddr.unix io-page.unix" archive(byte) = "dns-lwt.cma" diff --git a/lib/base64.ml b/lib/base64.ml deleted file mode 100644 index 67ad1c40e..000000000 --- a/lib/base64.ml +++ /dev/null @@ -1,84 +0,0 @@ -(* - * Copyright (c) 2006-2009 Citrix Systems Inc. - * 2010 Thomas Gazagnaire - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - *) - -let code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" -let padding = '=' - -let of_char x = if x = padding then 0 else String.index code x - -let to_char x = code.[x] - -let decode x = - let words = String.length x / 4 in - let padding = - if String.length x = 0 then 0 else ( - if x.[String.length x - 2] = padding - then 2 else (if x.[String.length x - 1] = padding then 1 else 0)) in - let output = String.make (words * 3 - padding) '\000' in - for i = 0 to words - 1 do - let a = of_char x.[4 * i + 0] - and b = of_char x.[4 * i + 1] - and c = of_char x.[4 * i + 2] - and d = of_char x.[4 * i + 3] in - let n = (a lsl 18) lor (b lsl 12) lor (c lsl 6) lor d in - let x = (n lsr 16) land 255 - and y = (n lsr 8) land 255 - and z = n land 255 in - output.[3 * i + 0] <- char_of_int x; - if i <> words - 1 || padding < 2 then output.[3 * i + 1] <- char_of_int y; - if i <> words - 1 || padding < 1 then output.[3 * i + 2] <- char_of_int z; - done; - output - -let encode x = - let length = String.length x in - let words = (length + 2) / 3 in (* rounded up *) - let padding = if length mod 3 = 0 then 0 else 3 - (length mod 3) in - let output = String.make (words * 4) '\000' in - let get i = if i >= length then 0 else int_of_char x.[i] in - for i = 0 to words - 1 do - let x = get (3 * i + 0) - and y = get (3 * i + 1) - and z = get (3 * i + 2) in - let n = (x lsl 16) lor (y lsl 8) lor z in - let a = (n lsr 18) land 63 - and b = (n lsr 12) land 63 - and c = (n lsr 6) land 63 - and d = n land 63 in - output.[4 * i + 0] <- to_char a; - output.[4 * i + 1] <- to_char b; - output.[4 * i + 2] <- to_char c; - output.[4 * i + 3] <- to_char d; - done; - for i = 1 to padding do - output.[String.length output - i] <- '='; - done; - output - -let test x = - let x' = encode x in - let x'' = decode x' in - if x <> x'' - then failwith (Printf.sprintf "Original: '%s'; encoded = '%s'; decoded = '%s'" x x' x'') - -let tests = [ "hello"; - "this is a basic test"; "1"; "22"; "333"; "4444"; "5555"; - "\000"; "\000\000"; "\000\000\000"; "\000\000\000\000" ] - -(* -let _ = List.iter test tests -*) diff --git a/lib/base64.mli b/lib/base64.mli deleted file mode 100644 index 7d4dcd1c9..000000000 --- a/lib/base64.mli +++ /dev/null @@ -1,23 +0,0 @@ -(* - * Copyright (c) 2006-2009 Citrix Systems Inc. - * 2010 Thomas Gazagnaire - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - *) - -(** decode a string encoded in base64. Will leave trailing NULLs on the string - padding it out to a multiple of 3 characters *) -val decode: string -> string - -(** encode a string into base64 *) -val encode: string -> string diff --git a/lib/dns.mlpack b/lib/dns.mlpack index d3009d46e..85bc4b930 100644 --- a/lib/dns.mlpack +++ b/lib/dns.mlpack @@ -1,6 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: e942d71b5a6cc804da6d12053a80e56d) -Base64 +# DO NOT EDIT (digest: cb594728b20def3b2937c01587b9ff91) Hashcons Loader Name diff --git a/lib/packet.ml b/lib/packet.ml index 5e887a24b..6b3ae57bf 100644 --- a/lib/packet.ml +++ b/lib/packet.ml @@ -862,6 +862,8 @@ let marshal_question ?(compress=true) (names, base, buf) q = set_q_cls buf (q_class_to_int q.q_class); names, base+sizeof_q, Cstruct.shift buf sizeof_q +exception Not_implemented + let parse_rdata names base t cls ttl buf = (** Drop remainder of buf to stop parsing and demuxing. *) let stop (x, _) = x in @@ -1031,6 +1033,7 @@ let parse_rdata names base t cls ttl buf = | RR_X25 -> let x25,_ = parse_charstr buf in X25 x25 + | _ -> raise Not_implemented let marshal_rdata names ?(compress=true) base rdbuf = function | A ip -> @@ -1182,6 +1185,7 @@ let parse_rdata names base t cls ttl buf = | UNKNOWN (typ, data) -> Cstruct.blit_from_string data 0 rdbuf 0 (String.length data); RR_UNSPEC, names, (String.length data) + | _ -> raise Not_implemented let compare_rdata a_rdata b_rdata = match (a_rdata, b_rdata) with diff --git a/lib/packet.mli b/lib/packet.mli index 837d8a707..151233097 100644 --- a/lib/packet.mli +++ b/lib/packet.mli @@ -1,6 +1,6 @@ (* * Copyright (c) 2011 Richard Mortier - * Copyright (c) 2011 Anil Madhavapeddy + * Copyright (c) 2011-2014 Anil Madhavapeddy * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -236,12 +236,20 @@ type rdata = val hex_of_string : string -> string val rdata_to_string : rdata -> string val rdata_to_rr_type : rdata -> rr_type + val marshal_rdata: int Name.Map.t -> ?compress:bool -> int -> t -> rdata -> rr_type * int Name.Map.t * int +(** Marshal the RR data into the DNS binary format. Raises [Not_implemented] + if the RR type is known but the logic is not implemented in the library + yet. *) + val compare_rdata : rdata -> rdata -> int +exception Not_implemented + (** Parse an RDATA element from a packet, given the set of already encountered - names, a starting index, and the type of the RDATA. *) + names, a starting index, and the type of the RDATA. Raises [Not_implemented] + if the RR type is not recognized. *) val parse_rdata : (int, label) Hashtbl.t -> int -> rr_type -> int -> int32 -> t -> rdata diff --git a/lib/resolvconf.ml b/lib/resolvconf.ml index f67e55b3e..d0666ea8a 100644 --- a/lib/resolvconf.ml +++ b/lib/resolvconf.ml @@ -1,5 +1,5 @@ (* - * Copyright (c) 2012 Anil Madhavapeddy + * Copyright (c) 2012-2014 Anil Madhavapeddy * Copyright (c) 2005 Fraser Research Inc. * * Permission to use, copy, modify, and distribute this software for any @@ -100,7 +100,7 @@ end module KeywordValue = struct type t = - | Nameserver of string * int option (* ipv4 dotted quad or ipv6 hex and colon *) + | Nameserver of Ipaddr.t * int option (* ipv4 dotted quad or ipv6 hex and colon *) | Port of int | Domain of string | Lookup of LookupValue.t list @@ -113,19 +113,19 @@ module KeywordValue = struct let ns_of_string ns = let open Re_str in match string_match (regexp "\\[\\(.+\\)\\]:\\([0-9]+\\)") ns 0 with - |false -> Nameserver (ns, None) + |false -> Nameserver (Ipaddr.of_string_exn ns, None) |true -> - let ns = matched_group 1 ns in + let server = Ipaddr.of_string_exn (matched_group 1 ns) in let port = try Some (int_of_string (matched_group 2 ns)) with _ -> None in - Nameserver (ns, port) + Nameserver (server, port) let string_of_ns ns = match ns with - |ns, None -> ns - |ns, Some p -> Printf.sprintf "[%s]:%d" ns p + |ns, None -> Ipaddr.to_string ns + |ns, Some p -> Printf.sprintf "[%s]:%d" (Ipaddr.to_string ns) p let of_string x = match split (String.lowercase x) with diff --git a/lib/resolvconf.mli b/lib/resolvconf.mli index 3d1525efc..c5aebb1b2 100644 --- a/lib/resolvconf.mli +++ b/lib/resolvconf.mli @@ -1,5 +1,5 @@ (* - * Copyright (c) 2012 Anil Madhavapeddy + * Copyright (c) 2012-2014 Anil Madhavapeddy * Copyright (c) 2005 Fraser Research Inc. * * Permission to use, copy, modify, and distribute this software for any @@ -41,7 +41,7 @@ end module KeywordValue : sig type t = - | Nameserver of string * int option + | Nameserver of Ipaddr.t * int option | Port of int | Domain of string | Lookup of LookupValue.t list @@ -56,6 +56,6 @@ end val map_line : string -> string option type t = KeywordValue.t list -val all_servers : KeywordValue.t list -> (string * int) list -val choose_server : KeywordValue.t list -> (string * int) option +val all_servers : KeywordValue.t list -> (Ipaddr.t * int) list +val choose_server : KeywordValue.t list -> (Ipaddr.t * int) option val search_domains : KeywordValue.t list -> string list diff --git a/lib_test/mirage/.gitignore b/lib_test/mirage/.gitignore new file mode 100644 index 000000000..1334fcde0 --- /dev/null +++ b/lib_test/mirage/.gitignore @@ -0,0 +1,7 @@ +Makefile +*.xl +_build +main.ml +mir-dns-client +log +*.xen diff --git a/lib_test/mirage/config.ml b/lib_test/mirage/config.ml new file mode 100644 index 000000000..5511c7d65 --- /dev/null +++ b/lib_test/mirage/config.ml @@ -0,0 +1,26 @@ +open Mirage + +let net = + try match Sys.getenv "NET" with + | "direct" -> `Direct + | _ -> `Socket + with Not_found -> `Socket + +let dhcp = + try match Sys.getenv "ADDR" with + | "dhcp" -> `Dhcp + | "static" -> `Static + with Not_found -> `Static + +let stack console = + match net, dhcp with + | `Direct, `Dhcp -> direct_stackv4_with_dhcp console tap0 + | `Direct, `Static -> direct_stackv4_with_default_ipv4 console tap0 + | `Socket, _ -> socket_stackv4 console [Ipaddr.V4.any] + +let client = + foreign "Unikernel.Client" @@ console @-> stackv4 @-> entropy @-> job + +let () = + add_to_ocamlfind_libraries [ "dns.mirage"; ]; + register "dns-client" [ client $ default_console $ stack default_console $ default_entropy ] diff --git a/lib_test/mirage/unikernel.ml b/lib_test/mirage/unikernel.ml new file mode 100644 index 000000000..20414b3a3 --- /dev/null +++ b/lib_test/mirage/unikernel.ml @@ -0,0 +1,34 @@ +open Lwt +open V1_LWT +open Printf + +let red fmt = sprintf ("\027[31m"^^fmt^^"\027[m") +let green fmt = sprintf ("\027[32m"^^fmt^^"\027[m") +let yellow fmt = sprintf ("\027[33m"^^fmt^^"\027[m") +let blue fmt = sprintf ("\027[36m"^^fmt^^"\027[m") + +let domain = "google.com" +let server = Ipaddr.V4.of_string_exn "8.8.8.8" + +module Client (C:CONSOLE) (S:STACKV4) (E:ENTROPY) = struct + + module U = S.UDPV4 + module DNS = Dns_resolver_mirage.Make(OS.Time)(S) + + let start c s e = + let t = DNS.create s in + Console.log_s c "Started, will begin resolving shortly..." >>= fun () -> + OS.Time.sleep 2.0 >>= fun () -> + while_lwt true do + Console.log_s c (green "Resolving %s" domain) + >>= fun () -> + DNS.gethostbyname t ~server "google.com" + >>= fun rl -> + Lwt_list.iter_s + (fun r -> + Console.log_s c (yellow " => %s" (Ipaddr.to_string r)) + ) rl + >>= fun () -> + OS.Time.sleep 1.0 + done +end diff --git a/lib_test/Makefile b/lib_test/unix/Makefile similarity index 100% rename from lib_test/Makefile rename to lib_test/unix/Makefile diff --git a/lib_test/client_test.ml b/lib_test/unix/client_test.ml similarity index 100% rename from lib_test/client_test.ml rename to lib_test/unix/client_test.ml diff --git a/lib_test/lwt_server.ml b/lib_test/unix/lwt_server.ml similarity index 100% rename from lib_test/lwt_server.ml rename to lib_test/unix/lwt_server.ml diff --git a/lib_test/rsa-sha256-test.private b/lib_test/unix/rsa-sha256-test.private similarity index 100% rename from lib_test/rsa-sha256-test.private rename to lib_test/unix/rsa-sha256-test.private diff --git a/lib_test/rsa-sha512-test.private b/lib_test/unix/rsa-sha512-test.private similarity index 100% rename from lib_test/rsa-sha512-test.private rename to lib_test/unix/rsa-sha512-test.private diff --git a/lib_test/test.zone b/lib_test/unix/test.zone similarity index 100% rename from lib_test/test.zone rename to lib_test/unix/test.zone diff --git a/lib_test/test2.zone b/lib_test/unix/test2.zone similarity index 100% rename from lib_test/test2.zone rename to lib_test/unix/test2.zone diff --git a/lib_test/time_server.ml b/lib_test/unix/time_server.ml similarity index 100% rename from lib_test/time_server.ml rename to lib_test/unix/time_server.ml diff --git a/lwt/dns-lwt-mirage.mldylib b/lwt/dns-lwt-mirage.mldylib new file mode 100644 index 000000000..f0a7b587d --- /dev/null +++ b/lwt/dns-lwt-mirage.mldylib @@ -0,0 +1,4 @@ +# OASIS_START +# DO NOT EDIT (digest: 7cf80eef16ecd71456b9376d65cacbf8) +Dns_resolver_mirage +# OASIS_STOP diff --git a/lwt/dns-lwt-mirage.mllib b/lwt/dns-lwt-mirage.mllib new file mode 100644 index 000000000..f0a7b587d --- /dev/null +++ b/lwt/dns-lwt-mirage.mllib @@ -0,0 +1,4 @@ +# OASIS_START +# DO NOT EDIT (digest: 7cf80eef16ecd71456b9376d65cacbf8) +Dns_resolver_mirage +# OASIS_STOP diff --git a/lwt/dns_resolver.ml b/lwt/dns_resolver.ml index dacb16cfa..1e25c5b19 100644 --- a/lwt/dns_resolver.ml +++ b/lwt/dns_resolver.ml @@ -33,38 +33,35 @@ type commfn = { cleanfn : unit -> unit Lwt.t; } -let log_info s = eprintf "INFO: %s\n%!" s -let log_debug s = eprintf "DEBUG: %s\n%!" s -let log_warn s = eprintf "WARN: %s\n%!" s - -let rec send_req txfn timerfn q = function - | 0 -> return () +let rec send_req txfn timerfn q = + function + | 0 -> return_unit | count -> - txfn q >>= fun _ -> - timerfn () >>= fun () -> - printf "retrying query for %d times\n%!" (4-count); - send_req txfn timerfn q (count - 1) + txfn q >>= fun _ -> + timerfn () >>= fun () -> + printf "retrying query for %d times\n%!" (4-count); + send_req txfn timerfn q (count - 1) let send_pkt client ({ txfn; rxfn; timerfn; cleanfn }) pkt = let module R = (val client : CLIENT) in let cqpl = R.marshal pkt in let resl = List.map (fun (ctxt,q) -> - (* make a new socket for each request flavor *) - (* start the requests in parallel and run them until success or timeout*) - let t, w = Lwt.wait () in - async (fun () -> pick [ - (send_req txfn timerfn q 4 - >>= fun () -> return (wakeup w (Error (R.timeout ctxt)))); - (catch - (fun () -> - rxfn (R.parse ctxt) - >>= fun r -> return (wakeup w (Answer r)) - ) - (fun exn -> return (wakeup w (Error exn))) - ) - ]); - t - ) cqpl in + (* make a new socket for each request flavor *) + (* start the requests in parallel and run them until success or timeout*) + let t, w = Lwt.wait () in + async (fun () -> pick [ + (send_req txfn timerfn q 4 + >>= fun () -> return (wakeup w (Error (R.timeout ctxt)))); + (catch + (fun () -> + rxfn (R.parse ctxt) + >>= fun r -> return (wakeup w (Answer r)) + ) + (fun exn -> return (wakeup w (Error exn))) + ) + ]); + t + ) cqpl in (* return an answer or all the errors if no request succeeded *) let rec select errors = function | [] -> fail (Dns_resolve_error errors) @@ -87,7 +84,6 @@ let resolve client try_lwt let id = (let module R = (val client : CLIENT) in R.get_id ()) in let q = Dns.Query.create ~id ~dnssec q_class q_type q_name in - log_info (sprintf "query: %s\n%!" (DP.to_string q)); send_pkt client commfn q >>= fun r -> commfn.cleanfn () @@ -96,7 +92,6 @@ let resolve client with exn -> commfn.cleanfn () >>= fun () -> - log_warn (sprintf "%s\n%!" (Printexc.to_string exn)); fail exn let gethostbyname @@ -107,22 +102,24 @@ let gethostbyname let domain = string_to_domain_name name in resolve (module Dns.Protocol.Client) commfn q_class q_type domain >|= fun r -> - List.fold_left (fun a x -> - match x.rdata with |A ip -> ip::a |_ -> a + List.fold_left (fun a x -> + match x.rdata with + | A ip -> Ipaddr.V4 ip :: a + | AAAA ip -> Ipaddr.V6 ip :: a + | _ -> a ) [] r.answers - |> List.rev + |> List.rev let gethostbyaddr ?(q_class:DP.q_class = DP.Q_IN) ?(q_type:DP.q_type = DP.Q_PTR) commfn addr - = + = let addr = for_reverse addr in - log_info (sprintf "gethostbyaddr: %s" (domain_name_to_string addr)); let open DP in resolve (module Dns.Protocol.Client) commfn q_class q_type addr >|= fun r -> - List.fold_left (fun a x -> + List.fold_left (fun a x -> match x.rdata with |PTR n -> (domain_name_to_string n)::a |_->a ) [] r.answers - |> List.rev + |> List.rev diff --git a/lwt/dns_resolver.mli b/lwt/dns_resolver.mli index 8043d5b08..8ba5ecd61 100644 --- a/lwt/dns_resolver.mli +++ b/lwt/dns_resolver.mli @@ -34,7 +34,7 @@ val resolve : val gethostbyname : ?q_class:Dns.Packet.q_class -> ?q_type:Dns.Packet.q_type -> commfn -> - string -> Ipaddr.V4.t list Lwt.t + string -> Ipaddr.t list Lwt.t val gethostbyaddr : ?q_class:Dns.Packet.q_class -> diff --git a/lwt/dns_resolver_unix.ml b/lwt/dns_resolver_unix.ml index cb4836dd6..57d33c08f 100644 --- a/lwt/dns_resolver_unix.ml +++ b/lwt/dns_resolver_unix.ml @@ -28,11 +28,11 @@ module DP = Dns.Packet let log_warn s = eprintf "WARN: %s\n%!" s let buflen = 4096 -let ns = "8.8.8.8" +let ns = Ipaddr.of_string_exn "8.8.8.8" let port = 53 let sockaddr addr port = - Lwt_unix.(ADDR_INET (Unix.inet_addr_of_string addr, port)) + Lwt_unix.(ADDR_INET (Ipaddr_unix.to_inet_addr addr, port)) let sockaddr_to_string = Lwt_unix.(function | ADDR_INET (a,p) -> sprintf "%s/%d" (Unix.string_of_inet_addr a) p @@ -46,7 +46,7 @@ let outfd addr port = let connect_to_resolver server port = let dst = sockaddr server port in - let ofd = outfd "0.0.0.0" 0 in + let ofd = outfd Ipaddr.(V4 V4.any) 0 in let cleanfn () = catch (fun () -> Lwt_unix.close ofd ) (fun e -> @@ -70,21 +70,21 @@ let connect_to_resolver server port = let resolve client ?(dnssec=false) - (server:string) (dns_port:int) + server dns_port (q_class:DP.q_class) (q_type:DP.q_type) (q_name:domain_name) = let commfn = connect_to_resolver server dns_port in resolve client ~dnssec commfn q_class q_type q_name let gethostbyname - ?(server:string = ns) ?(dns_port:int = port) + ?(server = ns) ?(dns_port = port) ?(q_class:DP.q_class = DP.Q_IN) ?(q_type:DP.q_type = DP.Q_A) name = let commfn = connect_to_resolver server dns_port in gethostbyname ~q_class ~q_type commfn name let gethostbyaddr - ?(server:string = ns) ?(dns_port:int = port) + ?(server = ns) ?(dns_port = port) ?(q_class:DP.q_class = DP.Q_IN) ?(q_type:DP.q_type = DP.Q_PTR) addr = @@ -95,13 +95,13 @@ open Dns.Resolvconf type t = { client : (module CLIENT); - servers : (string * int) list; + servers : (Ipaddr.t * int) list; search_domains : string list; } type config = [ | `Resolv_conf of string - | `Static of (string * int) list * string list + | `Static of (Ipaddr.t * int) list * string list ] module Resolv_conf = struct diff --git a/lwt/dns_resolver_unix.mli b/lwt/dns_resolver_unix.mli index d761d2069..691e6b70f 100644 --- a/lwt/dns_resolver_unix.mli +++ b/lwt/dns_resolver_unix.mli @@ -1,5 +1,6 @@ (* * Copyright (c) 2012 Richard Mortier + * Copyright (c) 2014 Anil Madhavapeddy * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,7 +22,7 @@ open Cstruct type t = { client : (module CLIENT); - servers : (string * int) list; + servers : (Ipaddr.t * int) list; search_domains : string list; } @@ -29,7 +30,7 @@ type t = { client resolution. *) type config = [ | `Resolv_conf of string (** A [resolv.conf] filename *) - | `Static of (string * int) list * string list (** A list of [hostname,port] of stub resolvers, and a search domain list *) + | `Static of (Ipaddr.t * int) list * string list (** A list of [hostname,port] of stub resolvers, and a search domain list *) ] (** Create a resolver instance that either uses the system @@ -38,10 +39,10 @@ type config = [ val create : ?client:(module CLIENT) -> ?config:config -> unit -> t Lwt.t (** Lookup a {! domain_name }. - @return the corresponding IPv4 addresses. + @return the corresponding IPv4/6 addresses. *) val gethostbyname : t -> ?q_class:q_class -> ?q_type:q_type - -> string -> Ipaddr.V4.t list Lwt.t + -> string -> Ipaddr.t list Lwt.t (** Reverse lookup an IPv4 address. @return the corresponding {! domain_name }s. diff --git a/lwt/mldig.ml b/lwt/mldig.ml index 74022f930..4125542de 100644 --- a/lwt/mldig.ml +++ b/lwt/mldig.ml @@ -68,7 +68,8 @@ let print_answers p = if al ob > 0 then print_section nm; List.iter (fun rr -> match rr.rdata with - |A ip-> print_rr rr "A" (Ipaddr.V4.to_string ip); + |A ip -> print_rr rr "A" (Ipaddr.V4.to_string ip); + |AAAA ip -> print_rr rr "AAAA" (Ipaddr.V6.to_string ip) |SOA (n1,n2,a1,a2,a3,a4,a5) -> print_rr rr "SOA" (sprintf "%s %s %lu %lu %lu %lu %lu" (string_of_name n1) @@ -77,6 +78,7 @@ let print_answers p = print_rr rr "MX" (sprintf "%d %s" pref (string_of_name host)); |CNAME a -> print_rr rr "CNAME" (string_of_name a) |NS a -> print_rr rr "NS" (string_of_name a) + |TXT s -> print_rr rr "TXT" (sprintf "%S" (String.concat "" s)) |_ -> printf "unknown\n" ) ob; if al ob > 0 then print_newline () @@ -109,23 +111,27 @@ let dig source_ip opt_dest_port q_class q_type args = |None, Some q_class -> (server, q_class, q_type, domains) |Some q_type, Some q_class -> (server, q_class, q_type, domains) end - ) (begin match res.Dns_resolver_unix.servers with - [] -> None | (s,p)::_ -> Some (s,Some p) end, + ) (begin + match res.Dns_resolver_unix.servers with + | [] -> None + | (s,p)::_ -> Some (Ipaddr.to_string s, Some p) + end, q_class, q_type, []) args in let domains = match domains with |[] -> ["."] |_ -> domains in printf ";; <<>> MLDiG 1.0 <<>>\n"; (* TODO put query domains from Sys.argv here *) - match server with - |None -> error "dig" "Must specify a DNS resolver (with @)" - |Some (x, opt_port) -> + match server with + | None -> error "dig" "Must specify a DNS resolver (with @)" + | Some (x, opt_port) -> debug (sprintf "Querying DNS server %s" x); let domain = string_to_domain_name (List.hd domains) in let _ = Lwt_unix.sleep (float_of_int timeout) >|= print_timeout in - lwt addr = try return Ipaddr.V4.(to_string (of_string_exn x)) + lwt addr = + try return (Ipaddr.of_string_exn x) with Ipaddr.Parse_error _ -> lwt addrs = Dns_resolver_unix.gethostbyname res x in match addrs with | [] -> error "dig" ("Could not resolve nameserver '"^x^"'") - | addr::_ -> return (Ipaddr.V4.to_string addr) + | addr::_ -> return addr in let port = match opt_port with None -> dns_port | Some p -> p in Dns_resolver_unix.(resolve diff --git a/mirage/dns-lwt-mirage.mldylib b/mirage/dns-lwt-mirage.mldylib new file mode 100644 index 000000000..f0a7b587d --- /dev/null +++ b/mirage/dns-lwt-mirage.mldylib @@ -0,0 +1,4 @@ +# OASIS_START +# DO NOT EDIT (digest: 7cf80eef16ecd71456b9376d65cacbf8) +Dns_resolver_mirage +# OASIS_STOP diff --git a/mirage/dns-lwt-mirage.mllib b/mirage/dns-lwt-mirage.mllib new file mode 100644 index 000000000..f0a7b587d --- /dev/null +++ b/mirage/dns-lwt-mirage.mllib @@ -0,0 +1,4 @@ +# OASIS_START +# DO NOT EDIT (digest: 7cf80eef16ecd71456b9376d65cacbf8) +Dns_resolver_mirage +# OASIS_STOP diff --git a/mirage/dns_resolver_mirage.ml b/mirage/dns_resolver_mirage.ml new file mode 100644 index 000000000..1df30386f --- /dev/null +++ b/mirage/dns_resolver_mirage.ml @@ -0,0 +1,117 @@ +(* + * Copyright (c) 2014 Anil Madhavapeddy + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +open Lwt +open Printf +open Dns.Name +open Dns.Operators +open Dns.Protocol +open Dns_resolver + +module DP = Dns.Packet + +let default_ns = Ipaddr.V4.of_string_exn "8.8.8.8" +let default_port = 53 + +module type S = sig + type t + type stack + + val create : stack -> t + + val resolve : + (module Dns.Protocol.CLIENT) -> + t -> Ipaddr.V4.t -> int -> + Dns.Packet.q_class -> + Dns.Packet.q_type -> + Dns.Name.domain_name -> + Dns.Packet.t Lwt.t + + val gethostbyname : t -> + ?server:Ipaddr.V4.t -> ?dns_port:int -> + ?q_class:Dns.Packet.q_class -> + ?q_type:Dns.Packet.q_type -> + string -> Ipaddr.t list Lwt.t + + val gethostbyaddr : t -> + ?server:Ipaddr.V4.t -> ?dns_port:int -> + ?q_class:Dns.Packet.q_class -> + ?q_type:Dns.Packet.q_type -> + Ipaddr.V4.t -> string list Lwt.t +end + +module Make(Time:V1_LWT.TIME)(S:V1_LWT.STACKV4) = struct + + type stack = S.t + type endp = Ipaddr.V4.t * int + + type t = { + s: S.t; + res: (endp, Dns_resolver.commfn) Hashtbl.t; + } + + let create s = + let res = Hashtbl.create 3 in + { s; res } + + let connect_to_resolver {s; res} ((dest_ip,dest_port) as endp) = + let udp = S.udpv4 s in + try + Hashtbl.find res endp + with Not_found -> + let timerfn () = Time.sleep 5.0 in + let mvar = Lwt_mvar.create_empty () in + (* TODO: test that port is free. Needs more functions exposed in tcpip *) + let source_port = Random.int 65300 + 1024 in + let callback ~src ~dst ~src_port buf = Lwt_mvar.put mvar buf in + let cleanfn () = return () in + S.listen_udpv4 s ~port:source_port callback; + let rec txfn buf = + Cstruct.of_bigarray buf |> + S.UDPV4.write ~source_port ~dest_ip ~dest_port udp in + let rec rxfn f = + Lwt_mvar.take mvar + >>= fun buf -> + match f (Dns.Buf.of_cstruct buf) with + | None -> rxfn f + | Some packet -> return packet + in + let commfn = { txfn; rxfn; timerfn; cleanfn } in + Hashtbl.add res endp commfn; + commfn + + let resolve client + s server dns_port + (q_class:DP.q_class) (q_type:DP.q_type) + (q_name:domain_name) = + let commfn = connect_to_resolver s (server,dns_port) in + resolve client commfn q_class q_type q_name + + let gethostbyname + s ?(server = default_ns) ?(dns_port = default_port) + ?(q_class:DP.q_class = DP.Q_IN) ?(q_type:DP.q_type = DP.Q_A) + name = + let commfn = connect_to_resolver s (server,dns_port) in + gethostbyname ~q_class ~q_type commfn name + + let gethostbyaddr + s ?(server = default_ns) ?(dns_port = default_port) + ?(q_class:DP.q_class = DP.Q_IN) ?(q_type:DP.q_type = DP.Q_PTR) + addr = + let commfn = connect_to_resolver s (server,dns_port) in + gethostbyaddr ~q_class ~q_type commfn addr + +end diff --git a/mirage/dns_resolver_mirage.mli b/mirage/dns_resolver_mirage.mli new file mode 100644 index 000000000..6839d7565 --- /dev/null +++ b/mirage/dns_resolver_mirage.mli @@ -0,0 +1,47 @@ +(* + * Copyright (c) 2014 Anil Madhavapeddy + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +val default_ns : Ipaddr.V4.t +val default_port : int + +module type S = sig + type t + type stack + + val create : stack -> t + + val resolve : + (module Dns.Protocol.CLIENT) -> + t -> Ipaddr.V4.t -> int -> + Dns.Packet.q_class -> + Dns.Packet.q_type -> + Dns.Name.domain_name -> + Dns.Packet.t Lwt.t + + val gethostbyname : t -> + ?server:Ipaddr.V4.t -> ?dns_port:int -> + ?q_class:Dns.Packet.q_class -> + ?q_type:Dns.Packet.q_type -> + string -> Ipaddr.t list Lwt.t + + val gethostbyaddr : t -> + ?server:Ipaddr.V4.t -> ?dns_port:int -> + ?q_class:Dns.Packet.q_class -> + ?q_type:Dns.Packet.q_type -> + Ipaddr.V4.t -> string list Lwt.t +end + +module Make(Time:V1_LWT.TIME)(S:V1_LWT.STACKV4) : S with type stack = S.t diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 9b9470586..fc303e5b8 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 7271659b71a607864dc15216336ce04c) *) +(* DO NOT EDIT (digest: 9d6284ed3fc4d61b11da36492200dea7) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -599,16 +599,22 @@ let package_default = [ ("dns", ["lib"], []); ("dns-lwt-core", ["lwt"], []); + ("dns-lwt-mirage", ["mirage"], []); ("dns-lwt", ["lwt"], []) ]; lib_c = []; flags = []; - includes = [("lwt", ["lib"]); ("lib_test", ["lib"; "lwt"])] + includes = + [ + ("mirage", ["lib"; "lwt"]); + ("lwt", ["lib"]); + ("lib_test/unix", ["lib"; "lwt"]) + ] } ;; let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; -# 613 "myocamlbuild.ml" +# 619 "myocamlbuild.ml" (* OASIS_STOP *) Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/opam b/opam new file mode 100644 index 000000000..d5d46d15e --- /dev/null +++ b/opam @@ -0,0 +1,33 @@ +opam-version: "1" +maintainer: "mirageos-devel@lists.xenproject.org" +authors: [ + "Anil Madhavapeddy" + "Tim Deegan" + "Richard Mortier" + "Haris Rotsos" + "David Sheets" + "Thomas Gazagnaire" +] +homepage: "https://github.com/mirage/ocaml-dns" +license: "LGPL-2.0 &\n LGPL-2.1 with OCaml linking exception &\n ISC" +tags: [ + "org:mirage" + "org:xapi-project" +] +build: [ + ["ocaml" "setup.ml" "-configure" "--prefix" prefix "--%{base-unix:enable}%-lwt"] + ["ocaml" "setup.ml" "-build"] + ["ocaml" "setup.ml" "-install"] +] +remove: [["ocamlfind" "remove" "dns"]] +depends: [ + "lwt" {>= "2.4.3"} + "cstruct" {>= "1.0.1"} + "ocamlfind" + "re" + "cmdliner" + "ipaddr" {>= "2.2.0"} + "io-page" + "base64" +] +ocaml-version: [>= "4.00.0"] diff --git a/setup.ml b/setup.ml index e83f4c4dc..002dc190e 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ -(* setup.ml generated for the first time by OASIS v0.4.1 *) +(* setup.ml generated for the first time by OASIS v0.4.4 *) (* OASIS_START *) -(* DO NOT EDIT (digest: c1fdb4f75244cfbde9f765bc57fa27d3) *) +(* DO NOT EDIT (digest: b0d7535f56218854326dc50bcf3f005c) *) (* Regenerated by OASIS v0.4.4 Visit http://oasis.forge.ocamlcore.org for more information and @@ -6844,7 +6844,7 @@ let setup_t = alpha_features = []; beta_features = []; name = "dns"; - version = "0.9.1"; + version = "0.10.0"; license = OASISLicense.DEP5License (OASISLicense.DEP5Unit @@ -6930,6 +6930,16 @@ let setup_t = flag_description = Some "run the internet-using tests"; flag_default = [(OASISExpr.EBool true, false)] }); + Flag + ({ + cs_name = "mirage"; + cs_data = PropList.Data.create (); + cs_plugin_data = [] + }, + { + flag_description = Some "build the Mirage library"; + flag_default = [(OASISExpr.EBool true, false)] + }); Library ({ cs_name = "dns"; @@ -6952,7 +6962,8 @@ let setup_t = FindlibPackage ("ipaddr", Some (OASISVersion.VGreaterEqual "2.2.0")); - FindlibPackage ("io-page", None) + FindlibPackage ("io-page", None); + FindlibPackage ("base64", None) ]; bs_build_tools = [ExternalTool "ocamlbuild"]; bs_c_sources = []; @@ -6967,7 +6978,6 @@ let setup_t = { lib_modules = [ - "Base64"; "Hashcons"; "Loader"; "Name"; @@ -7033,6 +7043,51 @@ let setup_t = lib_findlib_name = Some "lwt-core"; lib_findlib_containers = [] }); + Library + ({ + cs_name = "dns-lwt-mirage"; + cs_data = PropList.Data.create (); + cs_plugin_data = [] + }, + { + bs_build = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "mirage", true) + ]; + bs_install = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "mirage", true) + ]; + bs_path = "mirage"; + bs_compiled_object = Best; + bs_build_depends = + [ + FindlibPackage ("cstruct", None); + FindlibPackage ("lwt.syntax", None); + InternalLibrary "dns"; + InternalLibrary "dns-lwt-core"; + FindlibPackage ("tcpip", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])] + }, + { + lib_modules = ["Dns_resolver_mirage"]; + lib_pack = false; + lib_internal_modules = []; + lib_findlib_parent = Some "dns"; + lib_findlib_name = Some "mirage"; + lib_findlib_containers = [] + }); Library ({ cs_name = "dns-lwt"; @@ -7157,7 +7212,7 @@ let setup_t = true) ]; bs_install = [(OASISExpr.EBool true, false)]; - bs_path = "lib_test"; + bs_path = "lib_test/unix"; bs_compiled_object = Best; bs_build_depends = [ @@ -7195,7 +7250,7 @@ let setup_t = true) ]; bs_install = [(OASISExpr.EBool true, false)]; - bs_path = "lib_test"; + bs_path = "lib_test/unix"; bs_compiled_object = Best; bs_build_depends = [ @@ -7272,7 +7327,7 @@ let setup_t = pre_command = [(OASISExpr.EBool true, None)]; post_command = [(OASISExpr.EBool true, None)] }; - test_working_directory = Some "lib_test"; + test_working_directory = Some "lib_test/unix"; test_run = [ (OASISExpr.ENot (OASISExpr.EFlag "tests"), false); @@ -7294,7 +7349,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.4"; - oasis_digest = Some "7^\189\245\163T\197\006\164P3!{\156\230\141"; + oasis_digest = Some "\248\183x*f\015\216\155\143f\n\200\199\179\005\250"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -7302,6 +7357,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7306 "setup.ml" +# 7361 "setup.ml" (* OASIS_STOP *) let () = setup ();;