From d6237cefcb9fae0286a920b182e9bbc928a57c8a Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 3 Jun 2016 23:10:36 +0200 Subject: Ignore unknown address types when looking up hosts Previously, any function using a `ToSocketAddrs` input would fail if passed a hostname that resolves to an address type different from the ones recognized by Rust. This also changes the `LookupHost` iterator to only include the known address types, as a result, it doesn't have to return `Result`s any more, which are likely misinterpreted as failed name lookups. --- src/libstd/net/addr.rs | 7 +------ src/libstd/net/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src/libstd/net') diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index d510339f1c5..44a7823f82a 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -448,12 +448,7 @@ impl ToSocketAddrs for (Ipv6Addr, u16) { fn resolve_socket_addr(s: &str, p: u16) -> io::Result> { let ips = lookup_host(s)?; - let v: Vec<_> = ips.map(|a| { - a.map(|mut a| { - a.set_port(p); - a - }) - }).collect()?; + let v: Vec<_> = ips.map(|mut a| { a.set_port(p); a }).collect(); Ok(v.into_iter()) } diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index 45070460282..95df7f7eaeb 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -98,8 +98,8 @@ pub struct LookupHost(net_imp::LookupHost); addresses", issue = "27705")] impl Iterator for LookupHost { - type Item = io::Result; - fn next(&mut self) -> Option> { self.0.next() } + type Item = SocketAddr; + fn next(&mut self) -> Option { self.0.next() } } /// Resolve the host specified by `host` as a number of `SocketAddr` instances. -- cgit 1.4.1-3-g733a5