added dns-inverse-query
This commit is contained in:
parent
1689c545c8
commit
5c424ac160
17
dns.scm
17
dns.scm
|
@ -740,7 +740,22 @@
|
|||
(display "sorry, no answers received\n"))
|
||||
dns-msg))
|
||||
|
||||
|
||||
(define (dns-inverse-lookup ip)
|
||||
(let* ((ip-string (ip-string->in-addr ip))
|
||||
(question (if ip-string ; if name is a ip-addr, the query is a in-addr.arpa address
|
||||
(make-octet-query-message (random 256) ip-string 'ptr 'in)
|
||||
(error "dns-inverse-lookup: no valid ip")))
|
||||
(use-cache? #t)
|
||||
(nameserver (dns-find-nameserver))
|
||||
(check-answer (lambda (dns-msg) (if *debug* (display "check-answer\n"))
|
||||
(let* ((reply (dns-message:reply dns-msg))
|
||||
(answers (message:answers reply)))
|
||||
(not (null? answers)))))
|
||||
(dns-msg (dns-get-information question use-cache? nameserver check-answer))
|
||||
(answers (message:answers (dns-message:reply dns-msg))))
|
||||
(if (not (null? answers))
|
||||
(rr-data-ptr:name (rr:data (car answers)))
|
||||
#f)))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -735,6 +735,7 @@
|
|||
(define-interface dns-interface
|
||||
(export dns-clear-cache
|
||||
dns-lookup
|
||||
dns-inverse-lookup
|
||||
show-dns-message
|
||||
dns-find-nameserver))
|
||||
|
||||
|
|
Loading…
Reference in New Issue