aboutsummaryrefslogtreecommitdiff
path: root/src/config/options.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-04 18:48:52 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-04 18:48:52 +0200
commitb3f76f272abab8695b4406c6f0addcb58253c89d (patch)
treed7a2dd93548d7c35bab47865c2508b252683f9d3 /src/config/options.rs
parent2d39adcabb898686cb63c10713e9d9b63efc5601 (diff)
downloaddiplonat-b3f76f272abab8695b4406c6f0addcb58253c89d.tar.gz
diplonat-b3f76f272abab8695b4406c6f0addcb58253c89d.zip
Remove .rustfmt.toml and move to standard rustfmt format (4 spaces)
Diffstat (limited to 'src/config/options.rs')
-rw-r--r--src/config/options.rs109
1 files changed, 55 insertions, 54 deletions
diff --git a/src/config/options.rs b/src/config/options.rs
index 08cdd15..100c23c 100644
--- a/src/config/options.rs
+++ b/src/config/options.rs
@@ -11,79 +11,80 @@ use crate::config::RuntimeConfig;
/// Base configuration options
#[derive(Clone, Default, Deserialize)]
pub struct ConfigOptsBase {
- /// This node's private IP address [default: None]
- pub private_ip: Option<String>,
- /// Expiration time for IGD rules [default: 60]
- pub expiration_time: Option<u16>,
- /// Refresh time for IGD and Firewall rules [default: 300]
- pub refresh_time: Option<u16>,
- /// STUN server [default: stun.nextcloud.com:443]
- pub stun_server: Option<String>,
+ /// This node's private IP address [default: None]
+ pub private_ip: Option<String>,
+ /// Expiration time for IGD rules [default: 60]
+ pub expiration_time: Option<u16>,
+ /// Refresh time for IGD and Firewall rules [default: 300]
+ pub refresh_time: Option<u16>,
+ /// STUN server [default: stun.nextcloud.com:443]
+ pub stun_server: Option<String>,
}
/// ACME configuration options
#[derive(Clone, Default, Deserialize)]
pub struct ConfigOptsAcme {
- /// Whether ACME is enabled [default: false]
- #[serde(default)]
- pub enable: bool,
+ /// Whether ACME is enabled [default: false]
+ #[serde(default)]
+ pub enable: bool,
- /// The default domain holder's e-mail [default: None]
- pub email: Option<String>,
+ /// The default domain holder's e-mail [default: None]
+ pub email: Option<String>,
}
/// Consul configuration options
#[derive(Clone, Default, Deserialize)]
pub struct ConfigOptsConsul {
- /// Consul's node name [default: None]
- pub node_name: Option<String>,
- /// Consul's REST URL [default: "http://127.0.0.1:8500"]
- pub url: Option<String>,
- /// Consul's CA certificate [default: None]
- pub ca_cert: Option<String>,
- /// Skip TLS verification for Consul server [default: false]
- #[serde(default)]
- pub tls_skip_verify: bool,
- /// Consul's client certificate [default: None]
- pub client_cert: Option<String>,
- /// Consul's client key [default: None]
- pub client_key: Option<String>,
+ /// Consul's node name [default: None]
+ pub node_name: Option<String>,
+ /// Consul's REST URL [default: "http://127.0.0.1:8500"]
+ pub url: Option<String>,
+ /// Consul's CA certificate [default: None]
+ pub ca_cert: Option<String>,
+ /// Skip TLS verification for Consul server [default: false]
+ #[serde(default)]
+ pub tls_skip_verify: bool,
+ /// Consul's client certificate [default: None]
+ pub client_cert: Option<String>,
+ /// Consul's client key [default: None]
+ pub client_key: Option<String>,
}
/// Model of all potential configuration options
pub struct ConfigOpts {
- pub base: ConfigOptsBase,
- pub acme: ConfigOptsAcme,
- pub consul: ConfigOptsConsul,
+ pub base: ConfigOptsBase,
+ pub acme: ConfigOptsAcme,
+ pub consul: ConfigOptsConsul,
}
impl ConfigOpts {
- pub fn from_env() -> Result<RuntimeConfig> {
- let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_env()?;
- let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_env()?;
- let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_env()?;
+ pub fn from_env() -> Result<RuntimeConfig> {
+ let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_env()?;
+ let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_env()?;
+ let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_env()?;
- RuntimeConfig::new(Self {
- base: base,
- consul: consul,
- acme: acme,
- })
- }
+ RuntimeConfig::new(Self {
+ base: base,
+ consul: consul,
+ acme: acme,
+ })
+ }
- // Currently only used in tests
- #[cfg(test)]
- pub fn from_iter<Iter: Clone>(iter: Iter) -> Result<RuntimeConfig>
- where
- Iter: IntoIterator<Item = (String, String)>,
- {
- let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_iter(iter.clone())?;
- let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_iter(iter.clone())?;
- let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_iter(iter.clone())?;
+ // Currently only used in tests
+ #[cfg(test)]
+ pub fn from_iter<Iter: Clone>(iter: Iter) -> Result<RuntimeConfig>
+ where
+ Iter: IntoIterator<Item = (String, String)>,
+ {
+ let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_iter(iter.clone())?;
+ let consul: ConfigOptsConsul =
+ envy::prefixed("DIPLONAT_CONSUL_").from_iter(iter.clone())?;
+ let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_iter(iter.clone())?;
- RuntimeConfig::new(Self {
- base: base,
- consul: consul,
- acme: acme,
- })
- }
+ RuntimeConfig::new(Self {
+ base: base,
+ consul: consul,
+ acme: acme,
+ })
+ }
}