Skip to content

Commit

Permalink
don't build tokio-tun on non-linux targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Oct 4, 2023
1 parent 3a6f1be commit 0cec9f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/wireguard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 0 deletions common/wireguard/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]

use std::{
net::{Ipv4Addr, SocketAddr},
sync::Arc,
Expand Down
2 changes: 2 additions & 0 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 9 additions & 3 deletions gateway/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0cec9f6

Please sign in to comment.