add an "inert" mode to tfclient which does not link to nebula, allowing builds on platforms where CGo is unsupported

This commit is contained in:
c0repwn3r 2023-07-12 11:28:50 -04:00
parent 0c09476628
commit be4dc0d3a2
Signed by: core
GPG Key ID: FDBF740DADDCEECF
3 changed files with 25 additions and 1 deletions

View File

@ -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"]

View File

@ -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;

View File

@ -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<NebulaWorkerMessage>) {}