A small wrapper for libc to perform simple DNS lookups.
You can use the lookup_host
function to get a list of IP Addresses for a
given hostname, and the lookup_name
function to get the reverse dns entry for
the given IP Address.
```rust use dnslookup::{lookuphost, lookup_addr};
{
let hostname = "localhost";
let ips: Vec
{ use dnslookup::{lookuphost, lookup_addr};
let ip: std::net::IpAddr = "127.0.0.1".parse().unwrap(); let hostname = lookupaddr(&ip).unwrap(); asserteq!(hostname, "localhost"); } ```
```rust use dns_lookup::{getaddrinfo, AddrInfoHints};
{ use dns_lookup::{getaddrinfo, AddrInfoHints};
let hostname = "localhost";
let service = "ssh";
let hints = AddrInfoHints {
socktype: dns_lookup::SockType::Stream,
.. AddrInfoHints::default()
};
let sockets =
getaddrinfo(Some(hostname), Some(service), Some(hints))
.unwrap().collect::