gateway: enable wireguard at runtime

This commit is contained in:
Jon Häggblad
2023-11-17 09:35:23 +01:00
parent 808e3f0562
commit 2cbb2d8327
2 changed files with 14 additions and 7 deletions
+1
View File
@@ -94,4 +94,5 @@ sqlx = { version = "0.5", features = [
] }
[features]
default = ["wireguard"]
wireguard = ["nym-wireguard"]
+13 -7
View File
@@ -520,15 +520,21 @@ impl<St> Gateway<St> {
Arc::new(coconut_verifier),
);
// Once this is a bit more mature, make this a commandline flag instead of a compile time
// flag
#[cfg(feature = "wireguard")]
if let Err(err) = self
.start_wireguard(shutdown.subscribe().named("wireguard"))
.await
{
// that's a nasty workaround, but anyhow errors are generally nicer, especially on exit
bail!("{err}")
let wireguard_enabled = std::env::var("NYM_ENABLE_WIREGUARD")
.map(|v| v == "1")
.unwrap_or(false);
if wireguard_enabled {
if let Err(err) = self
.start_wireguard(shutdown.subscribe().named("wireguard"))
.await
{
// that's a nasty workaround, but anyhow errors are generally nicer, especially on exit
bail!("{err}")
}
}
}
info!("Finished nym gateway startup procedure - it should now be able to receive mix and client traffic!");