Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

adding parsing capabilities for dnskey records in the server lib #2

Merged
merged 9 commits into from
+1,300 −1,325
This page is out of date. Refresh to see the latest.
View
4 _oasis
@@ -10,7 +10,7 @@ BuildTools: ocamlbuild
Library dns
Path: lib
Findlibname: dns
- Pack: true
+# Pack: true
Modules:
Hashcons, Loader, Name, Operators, Packet, Query, RR, Trie, Wire,
Zone, Zone_lexer, Zone_parser
@@ -21,7 +21,7 @@ Library server
Findlibname: server
Modules: Dns_server
BuildDepends:
- lwt, lwt.unix, lwt.syntax, bitstring, bitstring.syntax, uri, dns
+ lwt, lwt.unix, lwt.syntax, bitstring, bitstring.syntax, uri, dns, cryptokit
FindlibParent: dns
Library resolver
View
1  _tags
@@ -45,6 +45,7 @@
<lib/*.ml{,i}>: pkg_cryptokit
<lib/*.ml{,i}>: pkg_bitstring.syntax
<lib/*.ml{,i}>: pkg_bitstring
+<lib/*.ml{,i}>: pkg_cryptokit
# Executable odig
<client/odig.{native,byte}>: use_dns
<client/odig.{native,byte}>: pkg_uri
View
2  lib/META
@@ -15,7 +15,7 @@ package "server" (
exists_if = "server.cma"
)
-package "server" (
+package "resolver" (
version = "0.9-dev"
description = "DNS protocol library for Lwt"
requires = "lwt lwt.unix lwt.syntax bitstring bitstring.syntax uri dns"
View
5 lib/RR.ml
@@ -63,6 +63,7 @@ and rdata =
| Unknown of int * cstr list
| WKS of (int32 * byte * cstr) list
| X25 of cstr list
+ | DNSKEY of (int * int * cstr) list
(* XXX add other RR types *)
(* wire-domain type for non-rfc1035 rdata? *)
@@ -93,6 +94,7 @@ let get_rrsets qtype sets cnames_ok =
| (`RT, RT _) -> true
| (`SRV, SRV _) -> true
| (`AAAA, AAAA _) -> true
+ | (`DNSKEY, DNSKEY _) -> true
| (`UNSPEC, UNSPEC _) -> true
| (`Unknown (t1, _), Unknown (t2, _)) -> (t1 = t2)
| (`MAILB, MB _) -> true
@@ -176,6 +178,9 @@ let merge_rrset new_rrset rrsets =
| (UNSPEC l1, UNSPEC l2) ->
(rrset.ttl, List.rev_append rest
({ ttl = rrset.ttl; rdata = UNSPEC (mfn l1 l2) } :: rrsets_done))
+ | (DNSKEY l1, DNSKEY l2) ->
+ (rrset.ttl, List.rev_append rest
+ ({ ttl = rrset.ttl; rdata = DNSKEY (mfn l1 l2) } :: rrsets_done))
| (Unknown (t1, l1), Unknown (t2, l2)) ->
if t1 = t2 then
(rrset.ttl, List.rev_append rest
View
1  lib/RR.mli
@@ -73,6 +73,7 @@ and rdata =
| Unknown of int * cstr list
| WKS of (int32 * byte * cstr) list
| X25 of cstr list
+ | DNSKEY of (int * int * cstr) list
(** Extract relevant RRSets given a query type, a list of RRSets and a flag to
say whether to return CNAMEs too.
View
10 lib/loader.ml
@@ -183,7 +183,15 @@ let add_srv_rr pri weight port target ttl owner db =
let add_unspec_rr str ttl owner db =
let s = hashcons_charstring str in
add_rrset { ttl; rdata = UNSPEC [ s ] } owner db
-
+
+let add_dnskey_rr flags typ key ttl owner db =
+ let flags = int16 flags in
+ let typ = int16 typ in
+ let tmp = Cryptokit.transform_string (Cryptokit.Base64.decode ()) key in
+ let dnskey = hashcons_charstring tmp in
+ add_rrset { ttl;
+ rdata = DNSKEY [ (flags, typ, dnskey) ] } owner db
+
(* State variables for the parser & lexer *)
type parserstate = {
View
2  lib/loader.mli
@@ -65,6 +65,8 @@ val add_aaaa_rr : string -> int32 -> domain_name -> db -> unit
val add_srv_rr :
int -> int -> int -> domain_name -> int32 -> domain_name -> db -> unit
val add_unspec_rr : string -> int32 -> domain_name -> db -> unit
+val add_txt_rr : string list -> int32 -> domain_name -> db -> unit
+val add_dnskey_rr : int -> int -> string -> int32 -> domain_name -> db -> unit
(** Raised if we already had an RRSet for this name and type, but with a
View
6 lib/packet.ml
@@ -28,6 +28,7 @@ type dnssec_alg =
| DSA
| ECC
| RSASHA1
+ | RSANSEC3
| RSASHA256
| RSASHA512
| UNKNOWN
@@ -37,6 +38,7 @@ let int_to_dnssec_alg = function
| 3 -> DSA
| 4 -> ECC
| 5 -> RSASHA1
+ | 7 -> RSANSEC3
| 8 -> RSASHA256
| 10 -> RSASHA512
| _ -> UNKNOWN
@@ -46,6 +48,7 @@ let dnssec_alg_to_int = function
| DSA -> 3
| ECC -> 4
| RSASHA1 -> 5
+ | RSANSEC3 -> 7
| RSASHA256 -> 8
| RSASHA512 -> 10
| UNKNOWN -> 6
@@ -55,6 +58,7 @@ let dnssec_alg_to_string = function
| DSA -> "DSA"
| ECC -> "ECC"
| RSASHA1 -> "RSASHA1"
+ | RSANSEC3 -> "RSANSEC3"
| RSASHA256 -> "RSASHA256"
| RSASHA512 -> "RSASHA512"
| UNKNOWN -> "UNK"
@@ -820,7 +824,7 @@ let marshal_dns dns =
| `DNSKEY (flags, alg, key)
->
let bkey = Cryptokit.(transform_string (Base64.encode_compact ()) key) in
- (BITSTRING { flags:16; 3:8; (dnssec_alg_to_int alg):8; bkey:-1:string }, `DNSKEY)
+ (BITSTRING { flags:16; 3:8; (dnssec_alg_to_int alg):8; key:-1:string }, `DNSKEY)
| `HINFO (cpu, os) -> BITSTRING { cpu:-1:string; os:-1:string }, `HINFO
| `ISDN (a, sa) -> (
(match sa with
View
4 lib/query.ml
@@ -194,6 +194,10 @@ let answer_query qname qtype trie =
| UNSPEC l
-> List.iter (fun s -> addrr (`UNSPEC (bytes s.H.node))) l
+ | DNSKEY l ->
+ List.iter (fun (fl, t, k) ->
+ addrr (`DNSKEY (fl, (Packet.int_to_dnssec_alg t), k.H.node))) l
+
| Unknown (t,l)
->
let s = l ||> (fun x -> x.H.node) |> String.concat "" in
View
3  lib/zone_parser.mly
@@ -303,7 +303,8 @@ rr:
/* RFC 2782 */
| TYPE_SRV s int16 s int16 s int16 s domain { add_srv_rr $3 $5 $7 $9 }
/* RFC 3596 */
- | TYPE_AAAA s ipv6 { add_aaaa_rr $3 }
+ | TYPE_AAAA s ipv6 { add_aaaa_rr $3 }
+ | TYPE_DNSKEY s int16 s int16 s int16 s charstring {add_dnskey_rr $3 $7 $9 }
/* Never properly defined: just testing the generic rdata format */
| TYPE_UNSPEC s generic_rdata { add_unspec_rr $3 }
View
1  lib_test/test.zone
@@ -78,3 +78,4 @@ types IN A 127.0.0.1
IN AAAA 0:0:0:0:0:FFFF:129.144.52.38
;; Dig's UNSPEC output is a wierd checksummed thing :(
IN UNSPEC \# 7 55 6E73 706563 21
+ IN DNSKEY 256 3 7 "AwEAAcAVwjuzHUCfFs7/U1BynkB/kGS37d3bXf8rBdeJul1F9I6nRD4mGyNNZOmgUis1QHxIoA5/xnI5Otsd0B3OcToie4UjFynnuibEcreT+GeakxskTbSbPyW4jdxshHeQ562Y1o0DZKOhHpDoD2q3uCJieBWABG5z7hm/TxSPBYN7"
View
80 myocamlbuild.ml
@@ -1,12 +1,12 @@
(* OASIS_START *)
-(* DO NOT EDIT (digest: 27a227d902cc3eef11413dc4b610e0e3) *)
+(* DO NOT EDIT (digest: 9edbf0d3b7105a926d73f4992e9d463e) *)
module OASISGettext = struct
-# 21 "/Users/mort/research/mirage/src/oasis/src/oasis/OASISGettext.ml"
+# 21 "/tmp/buildd/oasis-0.2.0/src/oasis/OASISGettext.ml"
- let ns_ str =
+ let ns_ str =
str
- let s_ str =
+ let s_ str =
str
let f_ (str : ('a, 'b, 'c, 'd) format4) =
@@ -18,13 +18,13 @@ module OASISGettext = struct
else
fmt2^^""
- let init =
+ let init =
[]
end
module OASISExpr = struct
-# 21 "/Users/mort/research/mirage/src/oasis/src/oasis/OASISExpr.ml"
+# 21 "/tmp/buildd/oasis-0.2.0/src/oasis/OASISExpr.ml"
@@ -46,18 +46,18 @@ module OASISExpr = struct
type 'a choices = (t * 'a) list
let eval var_get t =
- let rec eval' =
+ let rec eval' =
function
| EBool b ->
b
- | ENot e ->
+ | ENot e ->
not (eval' e)
| EAnd (e1, e2) ->
(eval' e1) && (eval' e2)
- | EOr (e1, e2) ->
+ | EOr (e1, e2) ->
(eval' e1) || (eval' e2)
| EFlag nm ->
@@ -76,19 +76,19 @@ module OASISExpr = struct
eval' t
let choose ?printer ?name var_get lst =
- let rec choose_aux =
+ let rec choose_aux =
function
| (cond, vl) :: tl ->
- if eval var_get cond then
- vl
+ if eval var_get cond then
+ vl
else
choose_aux tl
| [] ->
- let str_lst =
+ let str_lst =
if lst = [] then
s_ "<empty>"
else
- String.concat
+ String.concat
(s_ ", ")
(List.map
(fun (cond, vl) ->
@@ -97,10 +97,10 @@ module OASISExpr = struct
| None -> s_ "<no printer>")
lst)
in
- match name with
+ match name with
| Some nm ->
failwith
- (Printf.sprintf
+ (Printf.sprintf
(f_ "No result for the choice list '%s': %s")
nm str_lst)
| None ->
@@ -115,14 +115,14 @@ end
module BaseEnvLight = struct
-# 21 "/Users/mort/research/mirage/src/oasis/src/base/BaseEnvLight.ml"
+# 21 "/tmp/buildd/oasis-0.2.0/src/base/BaseEnvLight.ml"
module MapString = Map.Make(String)
type t = string MapString.t
let default_filename =
- Filename.concat
+ Filename.concat
(Sys.getcwd ())
"setup.data"
@@ -138,23 +138,23 @@ module BaseEnvLight = struct
let line =
ref 1
in
- let st_line =
+ let st_line =
Stream.from
(fun _ ->
try
- match Stream.next st with
+ match Stream.next st with
| '\n' -> incr line; Some '\n'
| c -> Some c
with Stream.Failure -> None)
in
- let lexer =
+ let lexer =
Genlex.make_lexer ["="] st_line
in
let rec read_file mp =
- match Stream.npeek 3 lexer with
+ match Stream.npeek 3 lexer with
| [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
- Stream.junk lexer;
- Stream.junk lexer;
+ Stream.junk lexer;
+ Stream.junk lexer;
Stream.junk lexer;
read_file (MapString.add nm value mp)
| [] ->
@@ -177,8 +177,8 @@ module BaseEnvLight = struct
end
else
begin
- failwith
- (Printf.sprintf
+ failwith
+ (Printf.sprintf
"Unable to load environment, the file '%s' doesn't exist."
filename)
end
@@ -188,23 +188,23 @@ module BaseEnvLight = struct
let buff =
Buffer.create ((String.length str) * 2)
in
- Buffer.add_substitute
+ Buffer.add_substitute
buff
- (fun var ->
- try
+ (fun var ->
+ try
var_expand (MapString.find var env)
with Not_found ->
- failwith
- (Printf.sprintf
+ failwith
+ (Printf.sprintf
"No variable %s defined when trying to expand %S."
- var
+ var
str))
str;
Buffer.contents buff
in
var_expand (MapString.find name env)
- let var_choose lst env =
+ let var_choose lst env =
OASISExpr.choose
(fun nm -> var_get nm env)
lst
@@ -212,7 +212,7 @@ end
module MyOCamlbuildFindlib = struct
-# 21 "/Users/mort/research/mirage/src/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
+# 21 "/tmp/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
(** OCamlbuild extension, copied from
* http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
@@ -311,7 +311,6 @@ module MyOCamlbuildFindlib = struct
* the "threads" package using the previous plugin.
*)
flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
- flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
@@ -321,7 +320,7 @@ module MyOCamlbuildFindlib = struct
end
module MyOCamlbuildBase = struct
-# 21 "/Users/mort/research/mirage/src/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+# 21 "/tmp/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
(** Base functions for writing myocamlbuild.ml
@author Sylvain Le Gall
@@ -336,7 +335,7 @@ module MyOCamlbuildBase = struct
type name = string
type tag = string
-# 55 "/Users/mort/research/mirage/src/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
+# 55 "/tmp/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
type t =
{
@@ -414,7 +413,7 @@ module MyOCamlbuildBase = struct
(* When ocaml link something that use the C library, then one
need that file to be up to date.
*)
- dep ["compile"; "ocaml"; "use_lib"^lib]
+ dep ["link"; "ocaml"; "use_lib"^lib]
[dir/"lib"^lib^"."^(!Options.ext_lib)];
(* TODO: be more specific about what depends on headers *)
@@ -455,8 +454,8 @@ let package_default =
MyOCamlbuildBase.lib_ocaml =
[
("lib/dns", ["lib"]);
- ("resolver/resolver", ["resolver"]);
- ("server/server", ["server"])
+ ("server/server", ["server"]);
+ ("resolver/resolver", ["resolver"])
];
lib_c = [];
flags = [];
@@ -465,6 +464,5 @@ let package_default =
let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
-# 469 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
View
2,506 setup.ml
1,228 additions, 1,278 deletions not shown
Something went wrong with that request. Please try again.