aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-09-14 16:09:38 +0200
committerAlex Auvolat <alex@adnab.me>2022-09-14 16:09:38 +0200
commite46dc2a8ef8a12e49aed3883b34b538b5f65ca31 (patch)
tree19bb547df310c40ead34b14b6bad3c8e1d408397 /src/util/config.rs
parent80fdbfb0aa1b7186db3aeef888c0954748a35c62 (diff)
downloadgarage-e46dc2a8ef8a12e49aed3883b34b538b5f65ca31.tar.gz
garage-e46dc2a8ef8a12e49aed3883b34b538b5f65ca31.zip
Allow for hostnames in bootstrap_peers and rpc_public_addr (fix #353)resolve-peer-names
Diffstat (limited to 'src/util/config.rs')
-rw-r--r--src/util/config.rs28
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)
}