crystal
Crystal Traffic 3.1
A private operations workspace for Nginx traffic, built with Crystal, Kemal and self-hosted Chart.js. Observe live requests, review heuristic signatures and investigate suspicious sources without sending telemetry to an analytics or enrichment service.
In the workspace
- Live request stream, status/method charts, source rankings and error logs.
- Structured search:
status:5xx path:/api,ip:192.0.2.1,method:POST score:75,bot:true; combine with severity and time-window filters. - Up to 12 browser-local saved views and CSV/JSON exports of the filtered retained requests.
- Incident correlation by source/endpoint, local triage and notes, captured timelines, summary JSON/Markdown and explicit private evidence exports. See the incident workspace guide.
- Endpoint error analysis, IP profiles, a 32-IP watchlist and a configurable alert inbox with acknowledgements. Alerts run while the page is open and live; they are not background notifications.
- Pause/resume, a working history scrubber, selectable replay speeds and authoritative reconnect snapshots.
- Log readability, ingestion/rejected-line counts, uptime, retention and profile-eviction indicators.
- Three visual themes, optional alert sounds, keyboard navigation, accessible dialogs, reduced motion and responsive layouts from 320 px upward.
Detection is passive. A signature match does not prove compromise, a successful attack or blocked traffic. The software is not an enforcing WAF. No guaranteed latency, memory use, throughput or zero-GC claim is made.
Security and retention
Authentication uses bcrypt and opaque random session tokens in a __Host- cookie with Secure, HttpOnly and SameSite=Strict. Sessions expire after 24 hours or one hour without an authenticated HTTP request. HTTP checks and open sockets share revocation; sockets recheck within five seconds. Login is throttled per canonical IP and by an aggregate CPU budget. Write requests and socket handshakes require the configured origin.
Nginx overwrites X-Real-IP using its trusted client address; Crystal only reads it from a loopback peer. Sensitive responses are not cached or indexed. Scripts are self-hosted under a CSP without inline script permission. Query values are redacted before storage, broadcast and export. IP addresses, path segments, query keys, user agents and error details may still be personal/sensitive data. No persistent event history or external enrichment is enabled.
Buffers retain 1,000 requests, 200 signatures and 100 server errors. At most 1,024 LRU IP profiles retain 10 paths and 16 user agents each. There are at most eight concurrent viewers, 32 queued outgoing messages per viewer, a 4 KiB incoming message limit and a bounded 512-record ingestion queue. Restarts clear in-memory data and sessions; startup seeds recent log history without inventing live bursts or escalating the current alert window.
See the audit, roadmap, operations and rollback guide, and incident runbook.
Development and verification
Requires Crystal 1.18.2+, Shards, Python 3 and Node 24 for development checks. Production is a compiled Crystal binary with static assets; Node is not a runtime dependency.
cd traffic-analyzer
shards install --production
npm ci --ignore-scripts
crystal spec
npm test
npm run check
mkdir -p bin
crystal build src/analyzer.cr --release --no-debug -o bin/analyzer
npx playwright install chromium
cd ..
python3 scripts/verify.py --binary traffic-analyzer/bin/analyzer --browser
The verification runner starts an isolated loopback server with synthetic documentation-range IPs, temporary log files and public fixture credentials. It tests authentication, origin checks, session cookies, body limits, viewer/message limits, credential redaction, live log tailing, logout revocation, browser interactions (including incident triage, snapshot stability and export privacy) and all seven panels at 320/390/768/1440 px. It never reads production credentials or writes production logs. Screenshots use synthetic data and are written to /tmp/crystal-qa by default.
For manual local development, explicitly export the configuration in .env.example using a real bcrypt hash, set APP_ORIGIN=http://127.0.0.1:8070, and run the binary from traffic-analyzer. Environment files are not loaded automatically. Secure cookies require an HTTPS deployment; the browser test uses Chromium's loopback exception.
Deployment and CI
The dedicated systemd service reads a release under .releases/current, rather than serving mutable checkout files. scripts/deploy.sh installs locked shards, runs specs and JavaScript logic tests, builds a release, validates real HTTP/WebSocket behavior, then atomically changes the release symlink and restarts the service. Failure restores the previous release. See operations for the one-time service/proxy setup.
GitHub Actions runs formatting, Crystal specs, JS checks, a release build and full browser regressions. Actions are pinned to commit hashes with read-only repository permissions. Dependabot covers GitHub Actions and the browser-test dependency; review Crystal/Kemal releases separately.
The operator interface is intentionally noindex. Public acquisition/SEO should use a separate marketing or synthetic demo surface, never real server telemetry.
crystal
- 0
- 0
- 3
- 0
- 0
- 28 minutes ago
- April 26, 2026
Sun, 29 Nov 2026 19:02:13 GMT