add lookup domain
This commit is contained in:
parent
07afc0afa5
commit
f66b956cc4
2 changed files with 10 additions and 1 deletions
|
@ -4,5 +4,8 @@ let () =
|
|||
let response = Network.send_request "8.8.8.8" "www.example.com" in
|
||||
print_endline (Utils.get_bytecode response);
|
||||
let dns_packet = Response.parse_dns_packet response in
|
||||
print_endline (Debug.dns_packet dns_packet)
|
||||
print_endline (Debug.dns_packet dns_packet);
|
||||
print_endline (Network.lookup_domain "example.com");
|
||||
print_endline (Network.lookup_domain "recurse.com");
|
||||
print_endline (Network.lookup_domain "www.metafilter.com")
|
||||
;;
|
||||
|
|
|
@ -11,3 +11,9 @@ let send_request dns url =
|
|||
let len, _ = recvfrom sock response 0 buffer_size [] in
|
||||
Bytes.sub response 0 len
|
||||
;;
|
||||
|
||||
let lookup_domain domain =
|
||||
let response = send_request "8.8.8.8" domain in
|
||||
let dns_packet = Response.parse_dns_packet response in
|
||||
Utils.get_ip (List.nth (List.rev dns_packet.answers) 0).data
|
||||
;;
|
||||
|
|
Reference in a new issue