From 515b98cae25abb18579bfabbc9d6b0b8d9a3a9f3 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Tue, 2 Sep 2025 20:17:01 +0300 Subject: [PATCH] logs --- dns/src/gurt_server.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dns/src/gurt_server.rs b/dns/src/gurt_server.rs index 1e8ca50..81c3e8f 100644 --- a/dns/src/gurt_server.rs +++ b/dns/src/gurt_server.rs @@ -327,6 +327,7 @@ async fn get_ca_certificate_content(app_state: &AppState) -> std::result::Result async fn serve_static_file(ctx: &ServerContext) -> Result { let path = ctx.path(); + log::info!("Static file request for path: '{}'", path); let file_path = if path == "/" || path == "" { "index.html" @@ -337,17 +338,21 @@ async fn serve_static_file(ctx: &ServerContext) -> Result { path } }; + log::info!("Resolved file_path: '{}'", file_path); if file_path.contains("..") || file_path.contains('/') || file_path.contains('\\') { + log::warn!("Invalid file path requested: '{}'", file_path); return Ok(GurtResponse::new(GurtStatusCode::Forbidden) .with_string_body("Invalid file path")); } let frontend_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("frontend"); let full_path = frontend_dir.join(file_path); + log::info!("Attempting to read file: '{}'", full_path.display()); match tokio::fs::read_to_string(&full_path).await { Ok(content) => { + log::info!("Successfully read file, content length: {} bytes", content.len()); let content_type = match full_path.extension().and_then(|ext| ext.to_str()) { Some("html") => "text/html", Some("lua") => "text/plain", @@ -362,7 +367,8 @@ async fn serve_static_file(ctx: &ServerContext) -> Result { .with_header("Content-Type", content_type) .with_string_body(&content)) } - Err(_) => { + Err(e) => { + log::error!("Failed to read file '{}': {}", full_path.display(), e); Ok(GurtResponse::new(GurtStatusCode::NotFound) .with_string_body("File not found")) }