add ip utils and print ip when its probably an IP adress in data field
This commit is contained in:
parent
231868e46d
commit
07afc0afa5
2 changed files with 11 additions and 1 deletions
|
@ -25,7 +25,9 @@ let dns_record ?(json = false) (record : Types.dns_record) =
|
|||
record.type_
|
||||
record.class_
|
||||
record.ttl
|
||||
(Utils.get_bytecode ~json record.data)
|
||||
(if Bytes.length record.data = 4
|
||||
then Utils.get_ip record.data
|
||||
else Utils.get_bytecode ~json record.data)
|
||||
;;
|
||||
|
||||
let dns_packet (record : Types.dns_packet) =
|
||||
|
|
|
@ -21,6 +21,14 @@ let get_bytecode ?(json = false) data =
|
|||
else result
|
||||
;;
|
||||
|
||||
let get_ip ip =
|
||||
Bytes.fold_left
|
||||
(fun acc n ->
|
||||
Printf.sprintf "%s%s%d" acc (if acc = "" then "" else ".") (int_of_char n))
|
||||
""
|
||||
ip
|
||||
;;
|
||||
|
||||
let get_obj_size obj = Obj.size (Obj.repr obj)
|
||||
|
||||
let new_buffer size list =
|
||||
|
|
Reference in a new issue