Improve parsing robustness with:
Rearrange the opam packages to eliminate optional dependencies, and have explicit and separate packages for the Lwt, Async and Mirage implementations. The opam and ocamlfind layouts now have the same names:
dns: the core packagedns-lwt: Lwt implementationdns-lwt-unix: Lwt Unix, including serversdns-async: Async implementation (this currently uses Unix)This layout is not compatible with the older releases which had ocamlfind subpackages, so an upper bound will be needed in OPAM for those. However, porting should be relatively straightforward to the new release, and in return your users will not have to deal with specifying a myriad of optional dependencies in OPAM.
Ipaddr_unix and Uri_services modules.Dns.Buf module that formerly wrapped Cstruct, now that the latter is a mature library.?alloc optional argument to functions that would formerly accept a Dns.Buf. By default, this allocates a single page, but consumers of this library can override it in order to supply their own allocation logic (e.g. a pool allocator).io-page to follow the Dns.Buf removal.All these changes were part of #132 by @hannesm.
hashcons package rather than containing a fork of it. Now that there is no LGPL (+ linking exception code left, clarify that the license is ISC. Previously the opam file claimed a mixture of licenses (#86 via @djs55)).Improve mDNS support (#82 from Luke Dunstan):
Dns.Probe to implement the unique name probing portion of mDNS.Dns.Name.Set construct.Mdns_resolver_mirage.Chain that is intended to compose an mDNS resolver with a normal DNS resolver such that *.local is resolved via mDNS and everything else is done with DNS.Dns.Query to not respond to queries for classes other than IN.Dns_server_unix.listen from answering more than one query (#80 from Magnus Skjegstad)name.ml to avoid breaking with Cstruct 1.6.0+.Dns_server.compose function to make it easier to build resolution pipelines (#58).Dns_server_mirage functor (#55).Dns_resolver.resolve_pkt to support custom query packets (#49).Async_kernel and Unix libraries. This introduces the dns.async-unix library.Packet.QM to Packet.Q_Normal and QU to Q_mDNS_Unicast for clarity and added more detailed doc comments. Added constructor function Packet.make_question for convenience. (#41io-page 1.3.0+ interface. (#40bool argument was added to Query.response_of_answer.Query.answer still exists but now Query.answer_multiple is also available for answering multiple questions in one query to produce a single answer (RFC 6762 section 5.3). One caveat is that responses may exceed the maximum message length, but that is not really specific to mDNS. Also, in theory multiple questions might require multiple separate response messages in unusual cases, but that is complicated and the library does not deal with that yet.Query.answer_multiple takes an optional function to allow the caller to control the cache-flush bit. This bit is only set for records that have been "confirmed as unique". Using a callback requires minimal changes here but puts the burden of maintaining uniqueness state elsewhere.Query.answer_multiple takes an optional function to filter the answer, in order to support "known answer suppression" (RFC 6762 section 7.1). Again, using a callback requires minimal change to the core, but later on the mDNS-specific known answer suppression logic could move into the Query module if that turns out to be simpler.PTR returns additional records for SRV and TXT, to support efficient service discovery.Trie.iter was added to support mDNS announcements.Bytes instead of String for eventual -safe-string support.Unit tests were added for some of the changes above, including a test-only dependency on pcap-format.
Dns.Packet.parse using pcap files.SRV records (#30).Bytes instead of String for mutable buffers.Base64 v2, which uses B64 as the toplevel module name to avoid linking conflicts with other community libraries.Dns.Buf.create now accepts an optional alloc parameter to use a custom allocator such as Io_page.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.Dns_resolver and Dns_resolver_unix to use Ipaddr.t more.mldig to use Ipaddr more and add more RR printing to match the conventional dig tool behaviour.Dns.Packet.Not_implemented exception rather than a pattern match failure.Base64 package instead of bundling one inside the Dns packed module.opam file for easier pinning.examples/ directory with a DNS forwarder sample (#21).commfn with a cleanup function.Dns.Buf.t buffers are page-aligned, via Io_page.Dns_resolver portable core, by adding a timeout argument to the commfn type.Dns_resolver_unix.process_of_zonebufs to handle multiple zone files.Dns_server_unix to expose multiple zonebuf functions.Ipaddr.V6 to restore IPv6/AAAA RR support.process_query now takes an output buffer so it doesn't have to overwrite the input buffer it just parsed.dns.lwt into a portable dns.lwt-core that doesn't require Unix (from which a Mirage version can be built). The only change to existing applications is that Unix-specific functions have shifted into Dns_resolver_unix or Dns_server_unix, with the module types for PROCESSOR and CLIENT unchanged.Dns_resolver.t is now a record type rather than a first-class module.mldig server and port options.Zone.load_zone to Zone.load and make it functional over Loader.db.Ipaddr.V4.t addresses in favor of Cstruct or Uri_IP representations.RRSIG signed type to be of the answer rather than the question.ANY queries.Buf to provide a nickname for char Bigarrays.Packet.{parse,marshal} to use Buf.t rather than exposing Cstruct.tPacket.parse to remove name map parameterProtocol with default DNS implementationsPROCESSOR module to Dns_server for contextual protocol extensionsDns_server.listen to accept processorDns_server.listen_with_zonebuf and Dns_server.listen_with_zonefile to Dns_server.serve_with_zonebuf and Dns_server.serve_with_zonefile resp.processor_of_process, process_of_zonebuf, eventual_process_of_zonefile, and serve_with_processor to Dns_serverQuery.query_answer to Query.answerQuery.response_of_answer and Query.answer_of_responseDns_resolver.build_query to Query.createDns_resolver now supports simultaneous resolver protocol requestsDns.Names.Map instead of Hashtbl.Lwt.unix instead of Lwt.sslDns_server subpackage.Dns_resolver.q_type/q_class arguments being ignored in the Lwt Dns_resolver (from Pierre Chambart).Dns.Resolvconf for parsing /etc/resolv.conf files on POSIX hosts.