diff options
author | Alex <alex@adnab.me> | 2022-09-14 16:37:18 +0200 |
---|---|---|
committer | Alex <alex@adnab.me> | 2022-09-14 16:37:18 +0200 |
commit | 82600acf776acecfa73fbf23d4c7107eaae81e09 (patch) | |
tree | 19bb547df310c40ead34b14b6bad3c8e1d408397 /src/util/config.rs | |
parent | 80fdbfb0aa1b7186db3aeef888c0954748a35c62 (diff) | |
parent | e46dc2a8ef8a12e49aed3883b34b538b5f65ca31 (diff) | |
download | garage-82600acf776acecfa73fbf23d4c7107eaae81e09.tar.gz garage-82600acf776acecfa73fbf23d4c7107eaae81e09.zip |
Merge pull request 'Allow for hostnames in bootstrap_peers and rpc_public_addr (fix #353)' (#383) from resolve-peer-names into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/383
Diffstat (limited to 'src/util/config.rs')
-rw-r--r-- | src/util/config.rs | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/util/config.rs b/src/util/config.rs index cccad101..5e113e13 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -3,12 +3,8 @@ use std::io::Read; use std::net::SocketAddr; use std::path::PathBuf; -use serde::de::Error as SerdeError; use serde::{de, Deserialize}; -use netapp::util::parse_and_resolve_peer_addr; -use netapp::NodeID; - use crate::error::Error; /// Represent the whole configuration @@ -43,11 +39,11 @@ pub struct Config { /// Address to bind for RPC pub rpc_bind_addr: SocketAddr, /// Public IP address of this node - pub rpc_public_addr: Option<SocketAddr>, + pub rpc_public_addr: Option<String>, /// Bootstrap peers RPC address - #[serde(deserialize_with = "deserialize_vec_addr", default)] - pub bootstrap_peers: Vec<(NodeID, SocketAddr)>, + #[serde(default)] + pub bootstrap_peers: Vec<String>, /// Consul host to connect to to discover more peers pub consul_host: Option<String>, /// Consul service name to use @@ -154,24 +150,6 @@ pub fn read_config(config_file: PathBuf) -> Result<Config, Error> { Ok(toml::from_str(&config)?) } -fn deserialize_vec_addr<'de, D>(deserializer: D) -> Result<Vec<(NodeID, SocketAddr)>, D::Error> -where - D: de::Deserializer<'de>, -{ - let mut ret = vec![]; - - for peer in <Vec<&str>>::deserialize(deserializer)? { - let (pubkey, addrs) = parse_and_resolve_peer_addr(peer).ok_or_else(|| { - D::Error::custom(format!("Unable to parse or resolve peer: {}", peer)) - })?; - for ip in addrs { - ret.push((pubkey, ip)); - } - } - - Ok(ret) -} - fn default_compression() -> Option<i32> { Some(1) } |