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 c8a7ce5cdf - Show all commits

View file

@ -11,7 +11,6 @@ pub struct Config {
pub metadata_dir: PathBuf,
pub data_dir: PathBuf,
#[serde(deserialize_with = "deserialize_addr")]
pub rpc_bind_addr: SocketAddr,
#[serde(deserialize_with = "deserialize_vec_addr")]
@ -50,14 +49,12 @@ pub struct TlsConfig {
#[derive(Deserialize, Debug, Clone)]
pub struct ApiConfig {
#[serde(deserialize_with = "deserialize_addr")]
pub api_bind_addr: SocketAddr,
pub s3_region: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct WebConfig {
#[serde(deserialize_with = "deserialize_addr")]
pub bind_addr: SocketAddr,
pub root_domain: String,
pub index: String,
@ -87,19 +84,6 @@ pub fn read_config(config_file: PathBuf) -> Result<Config, Error> {
Ok(toml::from_str(&config)?)
}
fn deserialize_addr<'de, D>(deserializer: D) -> Result<SocketAddr, D::Error>
where
D: de::Deserializer<'de>,
{
use std::net::ToSocketAddrs;
<&str>::deserialize(deserializer)?
.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"))
}
fn deserialize_vec_addr<'de, D>(deserializer: D) -> Result<Vec<SocketAddr>, D::Error>
where
D: de::Deserializer<'de>,