Permalink
Browse files

gethostbyname has a parameter for the dns server and port

  • Loading branch information...
1 parent d00e89e commit 01a3e83f88099773bc95666b238b91ebf7a0c4c9 crotsos committed May 26, 2012
Showing with 5 additions and 3 deletions.
  1. +4 −2 resolver/dns_resolver.ml
  2. +1 −1 resolver/dns_resolver.mli
View
6 resolver/dns_resolver.ml
@@ -109,9 +109,11 @@ let resolve
);
*)
-let gethostbyname name =
+let gethostbyname ?(server:string = ns) ?(dns_port:int = port)
+ name =
let domain = string_to_domain_name name in
- lwt r = resolve ~q_class:DP.(`IN) ~q_type:DP.(`A) domain in
+ lwt r = resolve ~server:server ~dns_port:dns_port ~q_class:DP.(`IN)
+ ~q_type:DP.(`A) domain in
return (DP.(r.answers ||> (fun x -> match x.rr_rdata with
|`A ip -> Some ip
| _ -> None
View
2 resolver/dns_resolver.mli
@@ -23,7 +23,7 @@ open Dns.Packet
@return the corresponding {! ipv4 } addresses.
*)
-val gethostbyname : string -> ipv4 list Lwt.t
+val gethostbyname : ?server:string -> ?dns_port:int ->string -> ipv4 list Lwt.t
(** Reverse lookup an {! ipv4 } address.

0 comments on commit 01a3e83

Please sign in to comment.