From be4dc0d3a2c4e87264e908e142a59bedd6db7ee8 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Wed, 12 Jul 2023 11:28:50 -0400 Subject: [PATCH] add an "inert" mode to tfclient which does not link to nebula, allowing builds on platforms where CGo is unsupported --- tfclient/Cargo.toml | 5 ++++- tfclient/src/main.rs | 6 ++++++ tfclient/src/nebulaworker_inert.rs | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tfclient/src/nebulaworker_inert.rs diff --git a/tfclient/Cargo.toml b/tfclient/Cargo.toml index fa5ae78..b0fb595 100644 --- a/tfclient/Cargo.toml +++ b/tfclient/Cargo.toml @@ -31,7 +31,7 @@ base64-serde = "0.7.0" dnapi-rs = { version = "0.1", path = "../dnapi-rs" } serde_yaml = "0.9.19" openssl-sys = { version = "0.9.83", features = ["vendored"] } -nebula-ffi = { version = "0.1", path = "../nebula-ffi" } +nebula-ffi = { version = "0.1", path = "../nebula-ffi", optional = true } [build-dependencies] serde = { version = "1.0.157", features = ["derive"] } @@ -49,3 +49,6 @@ license-file = "LICENSE.txt" maintainer-scripts = "debian/" systemd-units = { enable = false, unit-name = "tfclient@" } +[features] +default = ["linked-nebula"] +linked-nebula = ["nebula-ffi"] \ No newline at end of file diff --git a/tfclient/src/main.rs b/tfclient/src/main.rs index cc4a6d6..ba79d2e 100644 --- a/tfclient/src/main.rs +++ b/tfclient/src/main.rs @@ -18,7 +18,13 @@ pub mod apiworker; pub mod config; pub mod daemon; pub mod dirs; + +#[cfg(feature = "linked-nebula")] pub mod nebulaworker; +#[cfg(not(feature = "linked-nebula"))] +#[path = "nebulaworker_inert.rs"] +pub mod nebulaworker; + pub mod socketclient; pub mod socketworker; pub mod timerworker; diff --git a/tfclient/src/nebulaworker_inert.rs b/tfclient/src/nebulaworker_inert.rs new file mode 100644 index 0000000..e356183 --- /dev/null +++ b/tfclient/src/nebulaworker_inert.rs @@ -0,0 +1,15 @@ +// Code to handle the nebula worker +// This is an inert version of the nebula worker that does nothing, used when linking to nebula is diabled. +// This is useful if you wish to run your own nebula binary, for example on platforms where CGo does not work. + +use crate::config::TFClientConfig; +use crate::daemon::ThreadMessageSender; +use std::sync::mpsc::Receiver; + +pub enum NebulaWorkerMessage { + Shutdown, + ConfigUpdated, + WakeUp, +} + +pub fn nebulaworker_main(_config: TFClientConfig, _instance: String, _transmitter: ThreadMessageSender, _rx: Receiver) {} \ No newline at end of file