add support for using domain name in configuration #46
1 changed files with 17 additions and 10 deletions
|
@ -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)| {
|
||||||
|
let v = iter.collect::<Vec<_>>();
|
||||||
|
if v.is_empty() {
|
||||||
|
warn!("Error resolving \"{}\"", name)
|
||||||
}
|
}
|
||||||
Ok(res)
|
v
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue