apply json fix only when printing dns packet
This commit is contained in:
parent
b9015b2c55
commit
d745f3f0be
1 changed files with 11 additions and 5 deletions
16
lib/debug.ml
16
lib/debug.ml
|
@ -29,13 +29,19 @@ let dns_record ?(json = false) (record : Types.dns_record) =
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let dns_packet (record : Types.dns_packet) =
|
let dns_packet (record : Types.dns_packet) =
|
||||||
let list fn l = String.concat ", " (List.map (fun el -> fn el) l) in
|
let list l =
|
||||||
|
String.concat
|
||||||
|
", "
|
||||||
|
(match l with
|
||||||
|
| `Question lq -> List.map (fun el -> dns_question el) lq
|
||||||
|
| `Record lr -> List.map (fun el -> dns_record ~json:true el) lr)
|
||||||
|
in
|
||||||
Printf.sprintf
|
Printf.sprintf
|
||||||
"{ \"header\": %s, \"questions\": [%s], \"answers\": [%s], \"authorities\": [%s], \
|
"{ \"header\": %s, \"questions\": [%s], \"answers\": [%s], \"authorities\": [%s], \
|
||||||
\"additionals\": [%s] }"
|
\"additionals\": [%s] }"
|
||||||
(dns_header record.header)
|
(dns_header record.header)
|
||||||
(list dns_question record.questions)
|
(list (`Question record.questions))
|
||||||
(list dns_record record.answers)
|
(list (`Record record.answers))
|
||||||
(list dns_record record.authorities)
|
(list (`Record record.authorities))
|
||||||
(list dns_record record.additionals)
|
(list (`Record record.additionals))
|
||||||
;;
|
;;
|
||||||
|
|
Reference in a new issue