diff options
author | Alex Auvolat <alex@adnab.me> | 2021-12-25 19:19:19 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-12-25 19:23:18 +0100 |
commit | 3b9e75634aa06b6df0519e5d44fd6e5281712d09 (patch) | |
tree | d82e14884993895a13cdca78c7388de2e0846f0f /src/config/runtime.rs | |
parent | 4d4d453afa3edafe71db2ae60171b8696b38a3c9 (diff) | |
download | diplonat-3b9e75634aa06b6df0519e5d44fd6e5281712d09.tar.gz diplonat-3b9e75634aa06b6df0519e5d44fd6e5281712d09.zip |
Allow Diplonat to automatically detect it's private IP
Diffstat (limited to 'src/config/runtime.rs')
-rw-r--r-- | src/config/runtime.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/config/runtime.rs b/src/config/runtime.rs index eeb34f6..a1582e4 100644 --- a/src/config/runtime.rs +++ b/src/config/runtime.rs @@ -27,7 +27,7 @@ pub struct RuntimeConfigFirewall { #[derive(Debug)] pub struct RuntimeConfigIgd { - pub private_ip: String, + pub private_ip: Option<String>, pub expiration_time: Duration, pub refresh_time: Duration, } @@ -59,7 +59,7 @@ impl RuntimeConfig { impl RuntimeConfigAcme { pub fn new(opts: ConfigOptsAcme) -> Result<Option<Self>> { if !opts.enable { - return Ok(None) + return Ok(None); } let email = opts.email.expect( @@ -91,9 +91,7 @@ impl RuntimeConfigFirewall { impl RuntimeConfigIgd { pub(super) fn new(opts: ConfigOptsBase) -> Result<Self> { - let private_ip = opts - .private_ip - .expect("'DIPLONAT_PRIVATE_IP' environment variable is required"); + let private_ip = opts.private_ip; let expiration_time = Duration::from_secs( opts .expiration_time @@ -108,7 +106,7 @@ impl RuntimeConfigIgd { (currently: {}s)", expiration_time.as_secs(), refresh_time.as_secs() - )) + )); } Ok(Self { |