message: [network] Add ToSocketAddrs support for NetworkAddress
  For many TCB applications, we really just wanted a SocketAddr and don't
  have a special requirement on how the DNS or parsing work, this provides
  a conveience wrapper to convert from dns* and ip* to SocketAddr.
  Closes:
  Approved by: joshlind
diff: @@ -14,7 +14,7 @@ use std::{
  convert::{Into, TryFrom},
  fmt,
  iter::IntoIterator,
  - net::{self, IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
  + net::{self, IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs},
  num,
  str::FromStr,
  string::ToString,
  @@ -375,6 +375,24 @@ impl FromStr for NetworkAddress {
  }
  }
  +impl ToSocketAddrs for NetworkAddress {
  + type Iter = std::vec::IntoIter<SocketAddr>;
  +
  + fn to_socket_addrs(&self) -> Result<Self::Iter, std::io::Error> {
  + if let Some(((ipaddr, port), _)) = parse_ip_tcp(self.as_slice()) {
  + Ok(vec![SocketAddr::new(ipaddr, port)].into_iter())
  + } else if let Some(((ip_filter, dns_name, port), _)) = parse_dns_tcp(self.as_slice()) {
  + format!("{}:{}", dns_name, port).to_socket_addrs().map(|v| {
  + v.filter(|addr| ip_filter.matches(addr.ip()))
  + .collect::<Vec<_>>()
  + .into_iter()
  + })
  + } else {
  + Ok(vec![].into_iter())
  + }
  + }
  +}
  +
  impl TryFrom<Vec<Protocol>> for NetworkAddress {
  type Error = EmptyError;
  