aboutsummaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-04 18:48:10 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-04 18:48:10 +0200
commit2d39adcabb898686cb63c10713e9d9b63efc5601 (patch)
treee83b5424bc1e89901d66525e457b49e78901da42 /src/config
parent615f926618471998f85ee184b378b1128340367b (diff)
downloaddiplonat-2d39adcabb898686cb63c10713e9d9b63efc5601.tar.gz
diplonat-2d39adcabb898686cb63c10713e9d9b63efc5601.zip
cargo fmt
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,
})
}