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