cli: avoid data-dir initialization for version; create db parent dirs; redact generated passwords in CLI output
- Prevent 'nx9-wg version' from creating data directories by avoiding database initialization. - Create parent directories when an explicit --database path is provided. - Redact printed generated administrator passwords; announce file path or redact instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
commit
2ac6c81dfe
140 files changed
+31342
No files matched your search
@@ -0,0 +1,79 @@
|
||||
//! Operational Dashboard view model for nx9-wg appliance.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Dashboard summary state for system metrics, WireGuard, and network status.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DashboardState {
|
||||
// System status
|
||||
pub hostname: String,
|
||||
pub os_version: String,
|
||||
pub uptime_formatted: String,
|
||||
pub is_operational: bool,
|
||||
pub load_average: String,
|
||||
|
||||
// WireGuard
|
||||
pub total_interfaces: usize,
|
||||
pub active_interfaces: usize,
|
||||
pub total_peers: usize,
|
||||
pub online_peers: usize,
|
||||
pub latest_handshake_relative: String,
|
||||
|
||||
// Networking
|
||||
pub wan_ip: Option<String>,
|
||||
pub default_gateway: Option<String>,
|
||||
pub ipv4_forwarding_enabled: bool,
|
||||
pub ipv6_forwarding_enabled: bool,
|
||||
pub nat_masquerade_active: bool,
|
||||
|
||||
// Traffic telemetry
|
||||
pub aggregate_rx_bytes_formatted: String,
|
||||
pub aggregate_tx_bytes_formatted: String,
|
||||
|
||||
// Diagnostics & Drift
|
||||
pub diagnostics_pass_count: usize,
|
||||
pub diagnostics_warning_count: usize,
|
||||
pub diagnostics_fail_count: usize,
|
||||
pub reconciliation_drift_detected: bool,
|
||||
}
|
||||
|
||||
impl Default for DashboardState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
hostname: "nx9-wg-appliance".to_string(),
|
||||
os_version: "Linux native (nx9-wg v0.1.0)".to_string(),
|
||||
uptime_formatted: "3d 14h 22m".to_string(),
|
||||
is_operational: true,
|
||||
load_average: "0.15, 0.08, 0.03".to_string(),
|
||||
total_interfaces: 1,
|
||||
active_interfaces: 1,
|
||||
total_peers: 0,
|
||||
online_peers: 0,
|
||||
latest_handshake_relative: "None".to_string(),
|
||||
wan_ip: Some("198.51.100.1".to_string()),
|
||||
default_gateway: Some("198.51.100.254".to_string()),
|
||||
ipv4_forwarding_enabled: true,
|
||||
ipv6_forwarding_enabled: false,
|
||||
nat_masquerade_active: true,
|
||||
aggregate_rx_bytes_formatted: "0 B".to_string(),
|
||||
aggregate_tx_bytes_formatted: "0 B".to_string(),
|
||||
diagnostics_pass_count: 10,
|
||||
diagnostics_warning_count: 0,
|
||||
diagnostics_fail_count: 0,
|
||||
reconciliation_drift_detected: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_dashboard_state_default() {
|
||||
let state = DashboardState::default();
|
||||
assert!(state.is_operational);
|
||||
assert_eq!(state.total_interfaces, 1);
|
||||
assert!(!state.reconciliation_drift_detected);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user