280→ viewer_id: viewer_id.to_string(), 281→ })), 282→ }; 283→ 284→ let mut buf = Vec::new(); 285→ if stop_stream.encode(&mut buf).is_ok() { 286→ let _ = session_data.input_tx.send(buf).await; 287→ } 288→ } 289→ 290→ /// Remove a session (when agent disconnects) 291→ pub async fn remove_session(&self, session_id: SessionId) { 292→ let mut sessions = self.sessions.write().await; 293→ if let Some(session_data) = sessions.remove(&session_id) { 294→ let mut agents = self.agents.write().await; 295→ agents.remove(&session_data.info.agent_id); 296→ } 297→ } 298→ 299→ /// Disconnect a session by sending a disconnect message to the agent 300→ /// Returns true if the message was sent successfully 301→ pub async fn disconnect_session(&self, session_id: SessionId, reason: &str) -> bool { 302→ let sessions = self.sessions.read().await; 303→ if let Some(session_data) = sessions.get(&session_id) { 304→ // Create disconnect message 305→ use crate::proto; 306→ use prost::Message; 307→ 308→ let disconnect_msg = proto::Message { 309→ payload: Some(proto::message::Payload::Disconnect(proto::Disconnect { 310→ reason: reason.to_string(), 311→ })), 312→ }; 313→ 314→ let mut buf = Vec::new(); 315→ if disconnect_msg.encode(&mut buf).is_ok() { 316→ // Send via input channel (will be forwarded to agent's WebSocket) 317→ if session_data.input_tx.send(buf).await.is_ok() { 318→ return true; 319→ } 320→ } 321→ } 322→ false 323→ } 324→ 325→ /// List all active sessions 326→ pub async fn list_sessions(&self) -> Vec { 327→ let sessions = self.sessions.read().await; 328→ sessions.values().map(|s| s.info.clone()).collect() 329→ } 330→} 331→ 332→impl Default for SessionManager { 333→ fn default() -> Self { 334→ Self::new() 335→ } 336→} 337→ 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.