chore: initial import

This commit is contained in:
Sovereign
2025-12-18 00:29:15 +01:00
commit 789397eb33
22 changed files with 5944 additions and 0 deletions

52
node-agent/src/config.rs Normal file
View File

@@ -0,0 +1,52 @@
use std::env;
use uuid::Uuid;
/// Agent configuration loaded from environment variables.
#[derive(Debug, Clone)]
pub struct Config {
pub node_id: Uuid,
pub cc_url: String,
pub os_profile: String,
pub vaultmesh_root: String,
pub heartbeat_secs: u64,
}
impl Config {
/// Load configuration from environment variables.
///
/// | Variable | Default |
/// |---------------------------|----------------------------|
/// | VAULTMESH_NODE_ID | auto-generated UUID |
/// | VAULTMESH_CC_URL | http://127.0.0.1:8088 |
/// | VAULTMESH_OS_PROFILE | ArchVault |
/// | VAULTMESH_ROOT | /var/lib/vaultmesh |
/// | VAULTMESH_HEARTBEAT_SECS | 30 |
pub fn from_env() -> Self {
let node_id = env::var("VAULTMESH_NODE_ID")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or_else(Uuid::new_v4);
let cc_url = env::var("VAULTMESH_CC_URL")
.unwrap_or_else(|_| "http://127.0.0.1:8088".into());
let os_profile = env::var("VAULTMESH_OS_PROFILE")
.unwrap_or_else(|_| "ArchVault".into());
let vaultmesh_root = env::var("VAULTMESH_ROOT")
.unwrap_or_else(|_| "/var/lib/vaultmesh".into());
let heartbeat_secs = env::var("VAULTMESH_HEARTBEAT_SECS")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(30);
Self {
node_id,
cc_url,
os_profile,
vaultmesh_root,
heartbeat_secs,
}
}
}