1→//! GuruRMM Agent - Cross-platform Remote Monitoring and Management Agent 2→//! 3→//! This agent connects to the GuruRMM server, reports system metrics, 4→//! monitors services (watchdog), and executes remote commands. 5→ 6→mod config; 7→mod device_id; 8→mod ipc; 9→mod metrics; 10→mod service; 11→mod transport; 12→mod updater; 13→ 14→use anyhow::{Context, Result}; 15→use clap::{Parser, Subcommand}; 16→use std::path::PathBuf; 17→use std::sync::Arc; 18→use tokio::sync::RwLock; 19→use tracing::{error, info, warn}; 20→ 21→use crate::config::AgentConfig; 22→use crate::metrics::MetricsCollector; 23→use crate::transport::WebSocketClient; 24→ 25→/// GuruRMM Agent - Remote Monitoring and Management 26→#[derive(Parser)] 27→#[command(name = "gururmm-agent")] 28→#[command(author, version, about, long_about = None)] 29→struct Cli { 30→ /// Path to configuration file 31→ #[arg(short, long, default_value = "agent.toml")] 32→ config: PathBuf, 33→ 34→ /// Subcommand to run 35→ #[command(subcommand)] 36→ command: Option, 37→} 38→ 39→#[derive(Subcommand)] 40→enum Commands { 41→ /// Run the agent (default) 42→ Run, 43→ 44→ /// Install as a system service 45→ Install { 46→ /// Server WebSocket URL (e.g., wss://rmm-api.example.com/ws) 47→ #[arg(long)] 48→ server_url: Option, 49→ 50→ /// API key for authentication 51→ #[arg(long)] 52→ api_key: Option, 53→ 54→ /// Skip legacy service detection and cleanup 55→ #[arg(long, default_value = "false")] 56→ skip_legacy_check: bool, 57→ }, 58→ 59→ /// Uninstall the system service 60→ Uninstall, 61→ 62→ /// Start the installed service 63→ Start, 64→ 65→ /// Stop the installed service 66→ Stop, 67→ 68→ /// Show agent status 69→ Status, 70→ 71→ /// Generate a sample configuration file 72→ GenerateConfig { 73→ /// Output path for config file 74→ #[arg(short, long, default_value = "agent.toml")] 75→ output: PathBuf, 76→ }, 77→ 78→ /// Run as Windows service (called by SCM, not for manual use) 79→ #[command(hide = true)] 80→ Service, 81→} 82→ 83→/// Shared application state 84→pub struct AppState { 85→ pub config: AgentConfig, 86→ pub metrics_collector: MetricsCollector, 87→ pub connected: RwLock, 88→ pub last_checkin: RwLock>>, 89→ pub tray_policy: RwLock, 90→} 91→ 92→#[tokio::main] 93→async fn main() -> Result<()> { 94→ // Initialize logging 95→ tracing_subscriber::fmt() 96→ .with_env_filter( 97→ tracing_subscriber::EnvFilter::from_default_env() 98→ .add_directive("gururmm_agent=info".parse()?) 99→ .add_directive("info".parse()?), 100→ ) Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.