From c7c5c5f1354c6ff3022596253e8f449de0b35bfc Mon Sep 17 00:00:00 2001 From: icsboyx Date: Fri, 16 Jan 2026 15:17:57 +0100 Subject: [PATCH] feat: enhance upload handling and logging improvements --- data/html/index.html | 14 +++++++++++++- src/api.rs | 1 - src/data_mgt.rs | 12 ++++++++---- src/main.rs | 1 - 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/data/html/index.html b/data/html/index.html index 470b139..e564e01 100644 --- a/data/html/index.html +++ b/data/html/index.html @@ -62,6 +62,7 @@ - + \ No newline at end of file diff --git a/src/api.rs b/src/api.rs index 3785c7f..b00bf3c 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,4 +1,3 @@ -use actix_web::http::header; use actix_web::{HttpRequest, HttpResponse, get, post, web}; use base64::{Engine, engine::general_purpose}; diff --git a/src/data_mgt.rs b/src/data_mgt.rs index 3a1b8ba..234638b 100644 --- a/src/data_mgt.rs +++ b/src/data_mgt.rs @@ -111,8 +111,7 @@ impl AssetStorage { } pub async fn add_asset(&self, asset: Asset) { - print!("[{}] Adding asset: {}", chrono::Local::now().to_rfc3339(), asset.id()); - + println!("[{}] Adding asset: {}", chrono::Local::now().to_rfc3339(), asset.id()); self.assets.lock().await.push(asset); self.show_assets().await; } @@ -156,7 +155,8 @@ impl AssetStorage { pub async fn show_assets(&self) { for asset in self.assets.lock().await.iter() { println!( - "Asset ID: {}, Expires At: {}, MIME: {}, Size: {} bytes", + "[{}] Asset ID: {}, Expires At: {}, Mime: {}, Size: {} bytes", + chrono::Local::now().to_rfc3339(), asset.id(), asset.expires_at(), asset.mime(), @@ -192,11 +192,15 @@ impl RateLimiter { entry.push(asset_exp_time); (true, None) } else { + println!( + "[{}] Rate limit exceeded for IP: {}", + chrono::Local::now().to_rfc3339(), + client_ip + ); let first_to_expire = entry.iter().min().copied().unwrap(); let retry_after_ms = (first_to_expire - now).max(1); (false, Some(retry_after_ms)) }; - println!("{:?}", clients); ret_val } diff --git a/src/main.rs b/src/main.rs index ed09374..fb323b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,7 +76,6 @@ async fn view_asset(req: HttpRequest) -> actix_web::Result { #[route("/{tail:.*}", method = "GET", method = "POST")] async fn catch_all(req: HttpRequest, _payload: Option>) -> actix_web::Result { - println!("Catch-all route triggered for path: {}", req.uri().path()); let response = match req.uri().path() { path if STATIC_PAGES.contains(&path[1..].into()) => { let file_path = HTML_DIR.to_string() + path;