make it compatible with new changes
This commit is contained in:
parent
48589ff6e0
commit
f6aaf8f84d
1 changed files with 11 additions and 4 deletions
|
@ -1,8 +1,8 @@
|
||||||
open Unix
|
open Unix
|
||||||
open Query
|
open Query
|
||||||
|
|
||||||
let send_request dns url =
|
let send_request dns url record_type =
|
||||||
let query = build url 1 in
|
let query = build url record_type in
|
||||||
let sock = socket PF_INET SOCK_DGRAM 0 in
|
let sock = socket PF_INET SOCK_DGRAM 0 in
|
||||||
let server_addr = ADDR_INET (inet_addr_of_string dns, 53) in
|
let server_addr = ADDR_INET (inet_addr_of_string dns, 53) in
|
||||||
ignore (sendto sock query 0 (Bytes.length query) [] server_addr);
|
ignore (sendto sock query 0 (Bytes.length query) [] server_addr);
|
||||||
|
@ -13,7 +13,14 @@ let send_request dns url =
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let lookup_domain domain =
|
let lookup_domain domain =
|
||||||
let response = send_request "8.8.8.8" domain in
|
let response = send_request "8.8.8.8" domain Types.DNSType.a in
|
||||||
let dns_packet = Response.parse_dns_packet response in
|
let dns_packet = Response.parse_dns_packet response in
|
||||||
Utils.get_ip (List.nth (List.rev dns_packet.answers) 0).data
|
if dns_packet.header.num_answers > 0
|
||||||
|
then Some (List.nth dns_packet.answers 0).data
|
||||||
|
else None
|
||||||
|
;;
|
||||||
|
|
||||||
|
let send ip_address domain_name record_type =
|
||||||
|
let query = send_request ip_address domain_name record_type in
|
||||||
|
Response.parse_dns_packet query
|
||||||
;;
|
;;
|
||||||
|
|
Reference in a new issue