diff options
author | Alex Auvolat <alex@adnab.me> | 2023-04-04 19:06:33 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-04-04 19:06:33 +0200 |
commit | f410230240b270ec01cfbf0002cbe9d3849eb03b (patch) | |
tree | 7118b6281feaf23f5f30832ab2f997ea72902308 /src/config/runtime.rs | |
parent | b3f76f272abab8695b4406c6f0addcb58253c89d (diff) | |
download | diplonat-f410230240b270ec01cfbf0002cbe9d3849eb03b.tar.gz diplonat-f410230240b270ec01cfbf0002cbe9d3849eb03b.zip |
parse private_ip earlier
Diffstat (limited to 'src/config/runtime.rs')
-rw-r--r-- | src/config/runtime.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/config/runtime.rs b/src/config/runtime.rs index bffea52..45a29c3 100644 --- a/src/config/runtime.rs +++ b/src/config/runtime.rs @@ -1,9 +1,9 @@ use std::fs::File; use std::io::Read; -use std::net::{SocketAddr, ToSocketAddrs}; +use std::net::{Ipv4Addr, SocketAddr, ToSocketAddrs}; use std::time::Duration; -use anyhow::{anyhow, bail, Result}; +use anyhow::{anyhow, bail, Context, Result}; use crate::config::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul}; @@ -31,7 +31,7 @@ pub struct RuntimeConfigFirewall { #[derive(Debug)] pub struct RuntimeConfigIgd { - pub private_ip: Option<String>, + pub private_ip: Option<Ipv4Addr>, pub expiration_time: Duration, pub refresh_time: Duration, } @@ -137,7 +137,12 @@ impl RuntimeConfigFirewall { impl RuntimeConfigIgd { pub(super) fn new(opts: &ConfigOptsBase) -> Result<Self> { - let private_ip = opts.private_ip.clone(); + let private_ip = opts + .private_ip + .as_ref() + .map(|x| x.parse()) + .transpose() + .context("parse private_ip")?; let expiration_time = Duration::from_secs( opts.expiration_time .unwrap_or(super::EXPIRATION_TIME) |