aboutsummaryrefslogtreecommitdiff
path: root/src/config/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/runtime.rs')
-rw-r--r--src/config/runtime.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/config/runtime.rs b/src/config/runtime.rs
index 45a29c3..d1a3f89 100644
--- a/src/config/runtime.rs
+++ b/src/config/runtime.rs
@@ -26,6 +26,7 @@ pub struct RuntimeConfigConsul {
#[derive(Debug)]
pub struct RuntimeConfigFirewall {
+ pub ipv6_only: bool,
pub refresh_time: Duration,
}
@@ -38,7 +39,7 @@ pub struct RuntimeConfigIgd {
#[derive(Debug)]
pub struct RuntimeConfigStun {
- pub stun_server_v4: SocketAddr,
+ pub stun_server_v4: Option<SocketAddr>,
pub stun_server_v6: SocketAddr,
pub refresh_time: Duration,
}
@@ -48,7 +49,7 @@ pub struct RuntimeConfig {
pub acme: Option<RuntimeConfigAcme>,
pub consul: RuntimeConfigConsul,
pub firewall: RuntimeConfigFirewall,
- pub igd: RuntimeConfigIgd,
+ pub igd: Option<RuntimeConfigIgd>,
pub stun: RuntimeConfigStun,
}
@@ -57,7 +58,10 @@ impl RuntimeConfig {
let acme = RuntimeConfigAcme::new(opts.acme)?;
let consul = RuntimeConfigConsul::new(opts.consul)?;
let firewall = RuntimeConfigFirewall::new(&opts.base)?;
- let igd = RuntimeConfigIgd::new(&opts.base)?;
+ let igd = match opts.base.ipv6_only {
+ false => Some(RuntimeConfigIgd::new(&opts.base)?),
+ true => None,
+ };
let stun = RuntimeConfigStun::new(&opts.base)?;
Ok(Self {
@@ -131,7 +135,10 @@ impl RuntimeConfigFirewall {
let refresh_time =
Duration::from_secs(opts.refresh_time.unwrap_or(super::REFRESH_TIME).into());
- Ok(Self { refresh_time })
+ Ok(Self {
+ refresh_time,
+ ipv6_only: opts.ipv6_only,
+ })
}
}
@@ -189,9 +196,15 @@ impl RuntimeConfigStun {
let refresh_time =
Duration::from_secs(opts.refresh_time.unwrap_or(super::REFRESH_TIME).into());
+ let stun_server_v4 = match opts.ipv6_only {
+ false => Some(
+ stun_server_v4.ok_or(anyhow!("Unable to resolve STUN server's IPv4 address"))?,
+ ),
+ true => None,
+ };
+
Ok(Self {
- stun_server_v4: stun_server_v4
- .ok_or(anyhow!("Unable to resolve STUN server's IPv4 address"))?,
+ stun_server_v4,
stun_server_v6: stun_server_v6
.ok_or(anyhow!("Unable to resolve STUN server's IPv6 address"))?,
refresh_time,