mirage / ocaml-dns

OCaml implementation of the DNS protocol
BSD 2-Clause "Simplified" License
105 stars 43 forks source link

DNS.serve_with_zonefiles using last file only #69

Closed heidihoward closed 9 years ago

heidihoward commented 9 years ago

when I tried using DNS.serve_with_zonefiles and used dig, dig only returned the dns values of the last zone in the list, ie:

let zonefiles = ["example1.com.zone"; "example2.net.zone"]

module Main (C:CONSOLE) (K:KV_RO) (S:STACKV4) = struct

module U = S.UDPV4 module DNS = Dns_server_mirage.Make(K)(S)

let start c k s = let t = DNS.create s k in DNS.serve_with_zonefiles t ~port ~zonefiles end

gives:

[example1.com] dig @127.0.0.1 www.example1.com

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> @127.0.0.1 www.example1.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 3848 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available

;; QUESTION SECTION: ;www.example1.com. IN A

;; Query time: 1 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Mon May 11 12:09:29 UTC 2015 ;; MSG SIZE rcvd: 36

and

[example2.net] dig @127.0.0.1 www.example2.net

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> @127.0.0.1 www.example2.net ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19560 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3 ;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1500 ;; QUESTION SECTION: ;www.example2.net. IN A

;; ANSWER SECTION: www.example2.net. 3600 IN A 192.168.1.11

;; AUTHORITY SECTION: example2.net. 3600 IN NS ns2.example2.net. example2.net. 3600 IN NS ns1.example2.net.

;; ADDITIONAL SECTION: ns1.example2.net. 3600 IN A 192.168.1.11 ns2.example2.net. 3600 IN A 192.168.1.11

;; Query time: 2 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Mon May 11 12:11:52 UTC 2015 ;; MSG SIZE rcvd: 131

thanks again to Nick on mirageos-dev for spotting this

lcdunstan commented 9 years ago

The bug is a misunderstanding of the meaning of the first argument to String.concat: it's actually a separator, not a prefix. Bug fix and unit test to come later.

dsheets commented 9 years ago

I think process_of_zonebufs https://github.com/mirage/ocaml-dns/blob/master/lwt/dns_server.ml#L69 should be used rather than string manipulation. Any chance for a patch soonish? I'd like to publish 0.15.0 soon for #68.

lcdunstan commented 9 years ago

Yeah I had wondered about that. Patch coming today.

dsheets commented 9 years ago

This was fixed in #70 which was subsequently merged for dns.0.15.0 which has been released as ocaml/opam-repository#4092.