Add debugging stuff
This commit is contained in:
parent
278c9e5e17
commit
98f2058da6
3 changed files with 26 additions and 2 deletions
|
@ -1,5 +1,10 @@
|
||||||
open Dnstoy
|
open Dnstoy
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
print_endline (Utils.get_bytecode (Network.send_request "8.8.8.8" "www.example.com"))
|
let response = Network.send_request "8.8.8.8" "www.example.com" in
|
||||||
|
print_endline (Utils.get_bytecode response);
|
||||||
|
let response', dns_header = Response.parse_header response in
|
||||||
|
let dns_question = Response.parse_question response' in
|
||||||
|
Debug.print_dns_header dns_header;
|
||||||
|
Debug.print_dns_question dns_question
|
||||||
;;
|
;;
|
||||||
|
|
19
lib/debug.ml
Normal file
19
lib/debug.ml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
let print_dns_header (header : Types.dns_header) =
|
||||||
|
Printf.printf
|
||||||
|
"{ id = %d; flags = %d; num_questions = %d; num_answers = %d; num_authorities = %d; \
|
||||||
|
num_additionals = %d }\n"
|
||||||
|
header.id
|
||||||
|
header.flags
|
||||||
|
header.num_questions
|
||||||
|
header.num_answers
|
||||||
|
header.num_authorities
|
||||||
|
header.num_additionals
|
||||||
|
;;
|
||||||
|
|
||||||
|
let print_dns_question (question : Types.dns_question) =
|
||||||
|
Printf.printf
|
||||||
|
"{ name = '%s'; type_ = %d; class_ = %d }\n"
|
||||||
|
(Bytes.to_string question.name)
|
||||||
|
question.type_
|
||||||
|
question.class_
|
||||||
|
;;
|
2
lib/dune
2
lib/dune
|
@ -1,4 +1,4 @@
|
||||||
(library
|
(library
|
||||||
(name dnstoy)
|
(name dnstoy)
|
||||||
(modules types utils network query response)
|
(modules types utils debug network query response)
|
||||||
(libraries unix))
|
(libraries unix))
|
||||||
|
|
Reference in a new issue