feat: commit hash in banner, version command, file upload/download

This commit is contained in:
Helios Agent 2026-03-03 14:29:22 +01:00
parent cb86894369
commit f7d29a98d3
No known key found for this signature in database
GPG key ID: C8259547CD8309B5
8 changed files with 202 additions and 9 deletions

View file

@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use tokio_tungstenite::{connect_async_tls_with_config, tungstenite::Message, Connector};
use base64::Engine;
use helios_common::{ClientMessage, ServerMessage};
mod shell;
@ -20,7 +21,7 @@ mod windows_mgmt;
fn banner() {
println!();
println!(" {} HELIOS REMOTE", "".yellow().bold());
println!(" {} HELIOS REMOTE v{} ({})", "".yellow().bold(), env!("CARGO_PKG_VERSION"), env!("GIT_COMMIT"));
println!(" {}", "".repeat(45).dimmed());
}
@ -431,6 +432,53 @@ async fn handle_message(
}
}
ServerMessage::VersionRequest { request_id } => {
ClientMessage::VersionResponse {
request_id,
version: env!("CARGO_PKG_VERSION").to_string(),
commit: env!("GIT_COMMIT").to_string(),
}
}
ServerMessage::UploadRequest { request_id, path, content_base64 } => {
log_cmd!("upload → {}", path);
match (|| -> Result<(), String> {
let bytes = base64::engine::general_purpose::STANDARD
.decode(&content_base64)
.map_err(|e| format!("base64 decode: {e}"))?;
if let Some(parent) = std::path::Path::new(&path).parent() {
std::fs::create_dir_all(parent).map_err(|e| e.to_string())?;
}
std::fs::write(&path, &bytes).map_err(|e| e.to_string())?;
Ok(())
})() {
Ok(()) => {
log_ok!("Saved {}", path);
ClientMessage::Ack { request_id }
}
Err(e) => {
log_err!("upload failed: {e}");
ClientMessage::Error { request_id, message: e }
}
}
}
ServerMessage::DownloadRequest { request_id, path } => {
log_cmd!("download ← {}", path);
match std::fs::read(&path) {
Ok(bytes) => {
let size = bytes.len() as u64;
let content_base64 = base64::engine::general_purpose::STANDARD.encode(&bytes);
log_ok!("Sent {} bytes", size);
ClientMessage::DownloadResponse { request_id, content_base64, size }
}
Err(e) => {
log_err!("download failed: {e}");
ClientMessage::Error { request_id, message: format!("Read failed: {e}") }
}
}
}
ServerMessage::Ack { request_id } => {
ClientMessage::Ack { request_id }
}