//! Tauri commands for network scanning through SSH sessions. use tauri::State; use crate::scanner::{self, DiscoveredHost, PortResult}; use crate::AppState; /// Discover hosts on the remote network via ARP + ping sweep. /// `subnet` should be the first 3 octets, e.g. "192.168.1" #[tauri::command] pub async fn scan_network( session_id: String, subnet: String, state: State<'_, AppState>, ) -> Result, String> { let session = state.ssh.get_session(&session_id) .ok_or_else(|| format!("SSH session {} not found", session_id))?; scanner::scan_network(&session.handle, &subnet).await } /// Scan specific ports on a target host through an SSH session. #[tauri::command] pub async fn scan_ports( session_id: String, target: String, ports: Vec, state: State<'_, AppState>, ) -> Result, String> { let session = state.ssh.get_session(&session_id) .ok_or_else(|| format!("SSH session {} not found", session_id))?; scanner::scan_ports(&session.handle, &target, &ports).await } /// Quick scan of common ports (22, 80, 443, 3389, etc.) on a target. #[tauri::command] pub async fn quick_scan( session_id: String, target: String, state: State<'_, AppState>, ) -> Result, String> { let session = state.ssh.get_session(&session_id) .ok_or_else(|| format!("SSH session {} not found", session_id))?; scanner::quick_port_scan(&session.handle, &target).await }