1pub mod config;
4pub mod control;
5pub mod error;
6#[cfg(feature = "harness")]
7pub mod harness;
8#[cfg(feature = "m4a")]
9pub mod m4a;
10#[cfg(feature = "memory")]
11pub mod memory;
12#[cfg(feature = "m4a")]
13pub mod hub;
14pub mod node_controller;
15pub mod drain_consumer;
16#[cfg(feature = "harness")]
17pub mod kernel;
18#[cfg(feature = "harness")]
19pub mod kernel_runtime;
20pub mod operator_control;
21pub mod mesh_runtime;
22#[cfg(feature = "m4a")]
23pub mod node_sink;
24#[cfg(feature = "m4a")]
25pub mod messenger;
26#[cfg(feature = "m4a")]
27pub mod provision;
28#[cfg(feature = "m4a")]
29pub mod tasks;
30pub mod subservice;
31pub mod supervisor;
32
33pub use config::ServerConfig;
34pub use error::ServerError;
35pub use subservice::{State, Status, Subservice};
36pub use supervisor::Supervisor;
37
38pub fn build_subservices(config: &ServerConfig) -> Vec<Box<dyn Subservice>> {
40 #[allow(unused_mut)]
41 let mut services: Vec<Box<dyn Subservice>> = Vec::new();
42 #[cfg(feature = "harness")]
43 if config.harness_enabled {
44 if let Some(bin) = config.harness_bin.clone() {
45 services.push(Box::new(harness::HarnessSubservice::new(bin, config.harness_args.clone())));
46 }
47 }
48 #[cfg(feature = "m4a")]
49 if config.m4a_enabled {
50 services.push(Box::new(m4a::M4aSubservice::new(
51 &config.data_dir,
52 config.m4a_master_key_var.clone(),
53 )));
54 }
55 #[cfg(feature = "m4a")]
56 if let (true, Some(master), Some(c2_addr)) =
57 (config.m4a_enabled, config.m4a_master_key_var.clone(), config.provision_c2_addr.clone())
58 {
59 services.push(Box::new(provision::ProvisionSubservice::new(provision::ProvisionConfig {
60 data_dir: config.data_dir.clone(),
61 master_key_var: master,
62 c2_addr,
63 c2_token_var: config.provision_c2_token_var.clone(),
64 interval: std::time::Duration::from_secs(config.provision_interval_secs),
65 server_ref: config.m4a_server_ref.clone(),
66 mail_domain: config.mail_domain.clone(),
67 policy_path: config.policy_path.clone(),
68 })));
69 }
70 #[cfg(feature = "memory")]
71 services.push(Box::new(memory::MemorySubservice::new(
72 config.memory_bin.clone(),
73 &config.data_dir,
74 )));
75 let _ = config;
76 services
77}