don't build tokio-tun on non-linux targets

This commit is contained in:
Jędrzej Stuczyński
2023-10-04 16:41:12 +01:00
parent 3a6f1bec79
commit 0cec9f636f
4 changed files with 15 additions and 3 deletions
+2
View File
@@ -27,4 +27,6 @@ nym-task = { path = "../task" }
tap.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "net", "io-util"] }
[target.'cfg(target_os = "linux")'.dependencies]
tokio-tun = "0.9.0"
+2
View File
@@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]
use std::{
net::{Ipv4Addr, SocketAddr},
sync::Arc,
+2
View File
@@ -62,6 +62,8 @@ nym-statistics-common = { path = "../common/statistics" }
nym-task = { path = "../common/task" }
nym-types = { path = "../common/types" }
nym-validator-client = { path = "../common/client-libs/validator-client" }
[target.'cfg(target_os = "linux")'.dependencies]
nym-wireguard = { path = "../common/wireguard", optional = true }
[build-dependencies]
+9 -3
View File
@@ -370,11 +370,17 @@ impl<St> Gateway<St> {
// 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) = nym_wireguard::start_wireguard(shutdown.subscribe()).await {
// that's a nasty workaround, but anyhow errors are generally nicer, especially on exit
bail!("{err}")
{
#[cfg(target_os = "linux")]
if let Err(err) = nym_wireguard::start_wireguard(shutdown.subscribe()).await {
// that's a nasty workaround, but anyhow errors are generally nicer, especially on exit
bail!("{err}")
}
#[cfg(not(target_os = "linux"))]
panic!("wireguard is not supported on this platform")
}
info!("Finished nym gateway startup procedure - it should now be able to receive mix and client traffic!");
if let Err(err) = Self::wait_for_interrupt(shutdown).await {