Initial commit: stats-gateway gRPC service + dashboard + CLI

This commit is contained in:
2026-05-05 21:04:32 +05:00
commit 4059e94759
44 changed files with 2513 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
# stats-gateway
gRPC service collecting and publishing HTTP/TCP/DNS/TLS-handshake timing
metrics for two geo-distributed OpenSpeedTest nodes (FL — Finland, PL1 — Poland).
Powers the dashboard at <https://stats.projectshitpost.fun/>.
## Components
- **`cmd/server`** — gRPC server (TLS terminated by nginx, listens on loopback).
- **`cmd/collector`** — periodic prober (HTTP HEAD with httptrace), runs every 5 min via systemd timer.
- **`cmd/snapshot`** — generates `snapshot.json` for the dashboard, runs every 10 min.
- **`internal/probes`** — timing logic (DNS, TCP, TLS handshake, HTTP).
- **`internal/storage`** — SQLite WAL with embedded migrations.
- **`internal/service`** — gRPC handlers (`RecentResults`, `Aggregate`, `Tunnel`).
- **`proto/`** — protobuf definitions; generated Go in `gen/`.
- **`stats-site/`** — static dashboard (vanilla JS + canvas charts, no framework deps).
- **`psp-stats-cli/`** — Go CLI for querying the API.
- **`systemd/`** — ops units for running the service + timers.
- **`docs/AUTH.md`** — auth doc for the `Tunnel` method (Bearer JWT/HS256, used by internal CI agents).
## Build
make build # ./bin/{stats-gateway,stats-collector,stats-snapshot}
make test
cd psp-stats-cli && make build
## API
grpcurl -d '{"node":"fl","limit":5}' \
stats.projectshitpost.fun:443 stats.v1.SpeedStatus/RecentResults
See `proto/stats.proto`.
## License
MIT — see [LICENSE](./LICENSE).