aboutsummaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs3
-rw-r--r--src/config/runtime.rs15
2 files changed, 13 insertions, 5 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index a9cbd13..45ea975 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -5,7 +5,8 @@ mod runtime;
pub use options::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul};
pub use runtime::{
- RuntimeConfig, RuntimeConfigAcme, RuntimeConfigConsul, RuntimeConfigFirewall, RuntimeConfigIgd, RuntimeConfigStun
+ RuntimeConfig, RuntimeConfigAcme, RuntimeConfigConsul, RuntimeConfigFirewall, RuntimeConfigIgd,
+ RuntimeConfigStun,
};
pub const EXPIRATION_TIME: u16 = 300;
diff --git a/src/config/runtime.rs b/src/config/runtime.rs
index 50624de..f2d2a12 100644
--- a/src/config/runtime.rs
+++ b/src/config/runtime.rs
@@ -1,7 +1,7 @@
use std::fs::File;
use std::io::Read;
-use std::time::Duration;
use std::net::{SocketAddr, ToSocketAddrs};
+use std::time::Duration;
use anyhow::{anyhow, bail, Result};
@@ -165,7 +165,12 @@ impl RuntimeConfigStun {
pub(super) fn new(opts: &ConfigOptsBase) -> Result<Self> {
let mut stun_server_v4 = None;
let mut stun_server_v6 = None;
- for addr in opts.stun_server.as_deref().unwrap_or(super::STUN_SERVER).to_socket_addrs()? {
+ for addr in opts
+ .stun_server
+ .as_deref()
+ .unwrap_or(super::STUN_SERVER)
+ .to_socket_addrs()?
+ {
if addr.is_ipv4() {
stun_server_v4 = Some(addr);
}
@@ -177,8 +182,10 @@ impl RuntimeConfigStun {
let refresh_time = Duration::from_secs(opts.refresh_time.unwrap_or(super::REFRESH_TIME).into());
Ok(Self {
- stun_server_v4: stun_server_v4.ok_or(anyhow!("Unable to resolve STUN server's IPv4 address"))?,
- stun_server_v6: stun_server_v6.ok_or(anyhow!("Unable to resolve STUN server's IPv6 address"))?,
+ stun_server_v4: stun_server_v4
+ .ok_or(anyhow!("Unable to resolve STUN server's IPv4 address"))?,
+ stun_server_v6: stun_server_v6
+ .ok_or(anyhow!("Unable to resolve STUN server's IPv6 address"))?,
refresh_time,
})
}