All checks were successful
Rust CI / build-test (push) Successful in 1m22s
- Implemented `/api/stats` endpoint to return JSON metrics including active assets, total uploads, storage usage, and recent activity. - Created `stats.html` page to display real-time statistics with auto-refresh functionality. - Enhanced asset logging to include uploader IP and detailed event information for uploads and deletions. - Updated asset model to store uploader IP for audit purposes. - Improved logging functionality to ensure log directory exists before writing. - Refactored asset creation and management to support new features and logging.
2.7 KiB
2.7 KiB
Black Hole Share – AI Guide
- Purpose: lightweight Actix-Web service for ephemeral image/text sharing; uploads saved as JSON files on disk and purged after their TTL.
- Base directory is
data/: the server uses relative pathsdata/html/,data/logs/,data/storage/. Run from repo root locally; Docker mounts./data:/data. - HTTP entrypoint and routing live in src/main.rs:
/servesindex.html,/bhs/{id}servesview.html,/api/uploadand/api/content/{id}registered from the API module, catch-all serves other static files underhtml/(list cached at startup viaSTATIC_PAGES). - Request JSON bodies capped at ~3 MiB via
web::JsonConfig. Background cleanup task runs every 60s to delete expired assets instorage/. - Upload API in src/api.rs: accepts JSON
{ duration: minutes, content_type, content };text/plaincontent is stored raw bytes, other types are base64-decoded. On success returns{ "link": "/bhs/<uuid>" }. - Fetch API in src/api.rs: loads
{id}fromstorage/, rejects missing or expired assets, responds with original MIME and bytes. - Asset model and persistence in src/data_mgt.rs: assets serialized as JSON files named by UUID, with
expires_atcomputed fromshare_duration(minutes). Cleanup logs removals to stdout. - Logging helper in src/logs.rs: appends access lines with timing, IPs, scheme, UA to
logs/access.log; runs for every handled request. - Frontend upload page data/html/index.html: JS handles drag/drop, paste, or file picker; converts images to base64 or keeps text, POSTs to
/api/upload, shows returned link and copies to clipboard. Styling/theme in data/html/style.css. - Viewer page data/html/view.html: fetches
/api/content/{id}, renders images with zoom overlay or text with zoomable modal; shows error when content missing/expired. - Environment:
BIND_ADDRandBIND_PORT(defaults 0.0.0.0:8080) are read viaLazyLockon startup;tokiomulti-thread runtime used. - Build/dev:
cargo run --releasefrom repo root (ensuredata/exists withhtml/,logs/,storage/), or use Dockerfile (Arch base + rustup build) and docker-compose (Traefik labels, port 8080→80, volume./data:/data). - No test suite present; verify changes by running the server and exercising
/api/uploadand/api/content/{id}via the provided UI or curl. - When adding features, keep payload sizes small or adjust the JSON limit in src/main.rs; ensure new routes log via
log_to_filefor observability; clean up expired artifacts consistently withclear_assets()patterns.