Remove ACME config, not used as we are doing ACME in Tricot now
This commit is contained in:
parent
c356c4d1c4
commit
71bfd5be2d
3 changed files with 3 additions and 40 deletions
|
@ -3,10 +3,9 @@ mod options;
|
||||||
mod options_test;
|
mod options_test;
|
||||||
mod runtime;
|
mod runtime;
|
||||||
|
|
||||||
pub use options::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul};
|
pub use options::{ConfigOpts, ConfigOptsBase, ConfigOptsConsul};
|
||||||
pub use runtime::{
|
pub use runtime::{
|
||||||
RuntimeConfig, RuntimeConfigAcme, RuntimeConfigConsul, RuntimeConfigFirewall, RuntimeConfigIgd,
|
RuntimeConfig, RuntimeConfigConsul, RuntimeConfigFirewall, RuntimeConfigIgd, RuntimeConfigStun,
|
||||||
RuntimeConfigStun,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const EXPIRATION_TIME: u16 = 300;
|
pub const EXPIRATION_TIME: u16 = 300;
|
||||||
|
|
|
@ -24,17 +24,6 @@ pub struct ConfigOptsBase {
|
||||||
pub ipv6_only: bool,
|
pub ipv6_only: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ACME configuration options
|
|
||||||
#[derive(Clone, Default, Deserialize)]
|
|
||||||
pub struct ConfigOptsAcme {
|
|
||||||
/// Whether ACME is enabled [default: false]
|
|
||||||
#[serde(default)]
|
|
||||||
pub enable: bool,
|
|
||||||
|
|
||||||
/// The default domain holder's e-mail [default: None]
|
|
||||||
pub email: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Consul configuration options
|
/// Consul configuration options
|
||||||
#[derive(Clone, Default, Deserialize)]
|
#[derive(Clone, Default, Deserialize)]
|
||||||
pub struct ConfigOptsConsul {
|
pub struct ConfigOptsConsul {
|
||||||
|
@ -56,7 +45,6 @@ pub struct ConfigOptsConsul {
|
||||||
/// Model of all potential configuration options
|
/// Model of all potential configuration options
|
||||||
pub struct ConfigOpts {
|
pub struct ConfigOpts {
|
||||||
pub base: ConfigOptsBase,
|
pub base: ConfigOptsBase,
|
||||||
pub acme: ConfigOptsAcme,
|
|
||||||
pub consul: ConfigOptsConsul,
|
pub consul: ConfigOptsConsul,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +52,10 @@ impl ConfigOpts {
|
||||||
pub fn from_env() -> Result<RuntimeConfig> {
|
pub fn from_env() -> Result<RuntimeConfig> {
|
||||||
let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_env()?;
|
let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_env()?;
|
||||||
let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_env()?;
|
let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_env()?;
|
||||||
let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_env()?;
|
|
||||||
|
|
||||||
RuntimeConfig::new(Self {
|
RuntimeConfig::new(Self {
|
||||||
base: base,
|
base: base,
|
||||||
consul: consul,
|
consul: consul,
|
||||||
acme: acme,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,13 @@ use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Context, Result};
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
|
|
||||||
use crate::config::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul};
|
use crate::config::{ConfigOpts, ConfigOptsBase, ConfigOptsConsul};
|
||||||
|
|
||||||
// This code is inspired by the Trunk crate (https://github.com/thedodd/trunk)
|
// This code is inspired by the Trunk crate (https://github.com/thedodd/trunk)
|
||||||
|
|
||||||
// In this file, we take ConfigOpts and transform them into ready-to-use
|
// In this file, we take ConfigOpts and transform them into ready-to-use
|
||||||
// RuntimeConfig. We apply default values and business logic.
|
// RuntimeConfig. We apply default values and business logic.
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct RuntimeConfigAcme {
|
|
||||||
pub email: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RuntimeConfigConsul {
|
pub struct RuntimeConfigConsul {
|
||||||
pub node_name: String,
|
pub node_name: String,
|
||||||
|
@ -46,7 +41,6 @@ pub struct RuntimeConfigStun {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RuntimeConfig {
|
pub struct RuntimeConfig {
|
||||||
pub acme: Option<RuntimeConfigAcme>,
|
|
||||||
pub consul: RuntimeConfigConsul,
|
pub consul: RuntimeConfigConsul,
|
||||||
pub firewall: RuntimeConfigFirewall,
|
pub firewall: RuntimeConfigFirewall,
|
||||||
pub igd: Option<RuntimeConfigIgd>,
|
pub igd: Option<RuntimeConfigIgd>,
|
||||||
|
@ -55,7 +49,6 @@ pub struct RuntimeConfig {
|
||||||
|
|
||||||
impl RuntimeConfig {
|
impl RuntimeConfig {
|
||||||
pub fn new(opts: ConfigOpts) -> Result<Self> {
|
pub fn new(opts: ConfigOpts) -> Result<Self> {
|
||||||
let acme = RuntimeConfigAcme::new(opts.acme)?;
|
|
||||||
let consul = RuntimeConfigConsul::new(opts.consul)?;
|
let consul = RuntimeConfigConsul::new(opts.consul)?;
|
||||||
let firewall = RuntimeConfigFirewall::new(&opts.base)?;
|
let firewall = RuntimeConfigFirewall::new(&opts.base)?;
|
||||||
let igd = match opts.base.ipv6_only {
|
let igd = match opts.base.ipv6_only {
|
||||||
|
@ -65,7 +58,6 @@ impl RuntimeConfig {
|
||||||
let stun = RuntimeConfigStun::new(&opts.base)?;
|
let stun = RuntimeConfigStun::new(&opts.base)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
acme,
|
|
||||||
consul,
|
consul,
|
||||||
firewall,
|
firewall,
|
||||||
igd,
|
igd,
|
||||||
|
@ -74,20 +66,6 @@ impl RuntimeConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeConfigAcme {
|
|
||||||
pub fn new(opts: ConfigOptsAcme) -> Result<Option<Self>> {
|
|
||||||
if !opts.enable {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let email = opts.email.expect(
|
|
||||||
"'DIPLONAT_ACME_EMAIL' environment variable is required if 'DIPLONAT_ACME_ENABLE' == 'true'",
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Some(Self { email }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RuntimeConfigConsul {
|
impl RuntimeConfigConsul {
|
||||||
pub(super) fn new(opts: ConfigOptsConsul) -> Result<Self> {
|
pub(super) fn new(opts: ConfigOptsConsul) -> Result<Self> {
|
||||||
let node_name = opts
|
let node_name = opts
|
||||||
|
|
Loading…
Reference in a new issue