add ip utils and print ip when its probably an IP adress in data field

This commit is contained in:
Mylloon 2023-06-19 23:15:49 +02:00
parent 231868e46d
commit 07afc0afa5
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 11 additions and 1 deletions

View file

@ -25,7 +25,9 @@ let dns_record ?(json = false) (record : Types.dns_record) =
record.type_ record.type_
record.class_ record.class_
record.ttl 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) = let dns_packet (record : Types.dns_packet) =

View file

@ -21,6 +21,14 @@ let get_bytecode ?(json = false) data =
else result 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 get_obj_size obj = Obj.size (Obj.repr obj)
let new_buffer size list = let new_buffer size list =