aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.rs
diff options
context:
space:
mode:
authorTrinity Pointard <trinity.pointard@gmail.com>2021-03-18 21:04:30 +0100
committerTrinity Pointard <trinity.pointard@gmail.com>2021-03-18 21:04:30 +0100
commitf17cb6c969121d12937409f9ec0d204cad4a841c (patch)
treedbcc52170e5340d3be5e4c52781c950dd9d6eb5e /src/util/config.rs
parentc8a7ce5cdf8deb376752588ba1fd99675d8587e7 (diff)
downloadgarage-f17cb6c969121d12937409f9ec0d204cad4a841c.tar.gz
garage-f17cb6c969121d12937409f9ec0d204cad4a841c.zip
resolve domain to multiple addresses
And warn instead of failling when a domain can't be resolved
Diffstat (limited to 'src/util/config.rs')
-rw-r--r--src/util/config.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/util/config.rs b/src/util/config.rs
index 6b449459..9ff67711 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -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())
}