add support for using domain name in configuration #46

Merged
lx merged 4 commits from trinity-1686a/garage:bind-domain into master 2021-03-18 20:26:35 +00:00
Showing only changes of commit f17cb6c969 - Show all commits

View file

@ -90,14 +90,21 @@ where
{ {
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
let mut res = vec![]; Ok(<Vec<&str>>::deserialize(deserializer)?
for s in <Vec<&str>>::deserialize(deserializer)? { .iter()
res.push( .filter_map(|&name| {
s.to_socket_addrs() name.to_socket_addrs()
.map_err(|_| de::Error::custom("could not resolve to a socket address"))? .map(|iter| (name, iter))
.next() .map_err(|_| warn!("Error resolving \"{}\"", name))
.ok_or(de::Error::custom("could not resolve to a socket address"))?, .ok()
); })
} .map(|(name, iter)| {
Ok(res) let v = iter.collect::<Vec<_>>();
if v.is_empty() {
warn!("Error resolving \"{}\"", name)
}
v
})
.flatten()
.collect())
} }