Doc/updated documentation (#60)
* added documentation, updated repo pointer in the dashboard, added dashboard link highlighting and mionor fixes * added doc * added logo to dashboard * Fixed dashboard attack chart * Enhance fake data generation with varied request counts for better visualization * Add automatic migrations and support for latitude/longitude in IP stats * Update Helm chart version to 0.2.2 and add timezone configuration option --------- Co-authored-by: BlessedRebuS <patrick.difa@gmail.com>
This commit is contained in:
committed by
GitHub
parent
39d9d62247
commit
e93bcb959a
@@ -493,6 +493,47 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return
|
||||
user_agent = self._get_user_agent()
|
||||
|
||||
# Handle static files for dashboard
|
||||
if self.config.dashboard_secret_path and self.path.startswith(
|
||||
f"{self.config.dashboard_secret_path}/static/"
|
||||
):
|
||||
import os
|
||||
|
||||
file_path = self.path.replace(
|
||||
f"{self.config.dashboard_secret_path}/static/", ""
|
||||
)
|
||||
static_dir = os.path.join(os.path.dirname(__file__), "templates", "static")
|
||||
full_path = os.path.join(static_dir, file_path)
|
||||
|
||||
# Security check: ensure the path is within static directory
|
||||
if os.path.commonpath(
|
||||
[full_path, static_dir]
|
||||
) == static_dir and os.path.exists(full_path):
|
||||
try:
|
||||
with open(full_path, "rb") as f:
|
||||
content = f.read()
|
||||
self.send_response(200)
|
||||
if file_path.endswith(".svg"):
|
||||
self.send_header("Content-type", "image/svg+xml")
|
||||
elif file_path.endswith(".css"):
|
||||
self.send_header("Content-type", "text/css")
|
||||
elif file_path.endswith(".js"):
|
||||
self.send_header("Content-type", "application/javascript")
|
||||
else:
|
||||
self.send_header("Content-type", "application/octet-stream")
|
||||
self.send_header("Content-Length", str(len(content)))
|
||||
self.end_headers()
|
||||
self.wfile.write(content)
|
||||
return
|
||||
except Exception as e:
|
||||
self.app_logger.error(f"Error serving static file: {e}")
|
||||
|
||||
self.send_response(404)
|
||||
self.send_header("Content-type", "text/plain")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"Not found")
|
||||
return
|
||||
|
||||
if (
|
||||
self.config.dashboard_secret_path
|
||||
and self.path == self.config.dashboard_secret_path
|
||||
|
||||
Reference in New Issue
Block a user