diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 16:26:02 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-30 16:26:02 -0800 |
| commit | b936fb3d1643711b7bd041b7aca4d203ebb3cc7a (patch) | |
| tree | 50f7f0b5fbdc08749072c8b75809464bc62cdcad /src/libstd/io | |
| parent | 2dd519230f581af51e396acd2cead844bc3643d5 (diff) | |
| parent | e6c8b8f480712d346c9b92f06217b4c56c15610c (diff) | |
| download | rust-b936fb3d1643711b7bd041b7aca4d203ebb3cc7a.tar.gz rust-b936fb3d1643711b7bd041b7aca4d203ebb3cc7a.zip | |
rollup merge of #20286: murarth/get-address-name
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/net/addrinfo.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs index 69ba64d856e..e8fbb121181 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/io/net/addrinfo.rs @@ -10,8 +10,8 @@ //! Synchronous DNS Resolution //! -//! Contains the functionality to perform DNS resolution in a style related to -//! `getaddrinfo()` +//! Contains the functionality to perform DNS resolution or reverse lookup, +//! in a style related to `getaddrinfo()` and `getnameinfo()`, respectively. #![allow(missing_docs)] @@ -24,6 +24,7 @@ use io::{IoResult}; use io::net::ip::{SocketAddr, IpAddr}; use option::Option; use option::Option::{Some, None}; +use string::String; use sys; use vec::Vec; @@ -83,6 +84,12 @@ pub fn get_host_addresses(host: &str) -> IoResult<Vec<IpAddr>> { lookup(Some(host), None, None).map(|a| a.into_iter().map(|i| i.address.ip).collect()) } +/// Reverse name resolution. Given an address, returns the corresponding +/// hostname. +pub fn get_address_name(addr: IpAddr) -> IoResult<String> { + sys::addrinfo::get_address_name(addr) +} + /// Full-fledged resolution. This function will perform a synchronous call to /// getaddrinfo, controlled by the parameters /// |
