From 0f5f4b8dc2735d299d2151d8d3a3401713e958a3 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 4 Jul 2023 10:49:55 +0200 Subject: [PATCH] still kinda wip since i think this code isnt working --- lib/response.ml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/response.ml b/lib/response.ml index 376b63f..28c4861 100644 --- a/lib/response.ml +++ b/lib/response.ml @@ -49,12 +49,25 @@ let parse_record reader = let data = bytes_forward reader.data (offset_name + reader.pointer) in let data_len = unpack_short_be data 8 in let record_len = 10 in + let type_ = unpack_short_be data 0 in ( { reader with pointer = reader.pointer + offset_name + record_len + data_len } , { name - ; type_ = unpack_short_be data 0 + ; type_ ; class_ = unpack_short_be data 2 ; ttl = unpack_int_be data 4 - ; data = Bytes.sub data record_len data_len + ; data = + (let raw_data = Bytes.sub data record_len data_len in + match type_ with + | v when v = DNSType.ns -> + print_endline "aaaaaaaaaaaaa"; + let r1, r2 = + decode_name + { reader with pointer = reader.pointer + offset_name + record_len } + in + Printf.printf "%s - %d\n" (String.of_bytes r1) r2; + r1 + | v when v = DNSType.a -> String.to_bytes (get_ip raw_data) + | _ -> raw_data) } ) ;;