1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Status page and uptime monitor
//!
//! Checks HTTP and TCP targets in the background, keeps a history, and serves a
//! public status page that updates live (Server-Sent Events), a JSON API, and an
//! API-key protected admin API for managing monitors. Stops cleanly on CTRL+C /
//! SIGTERM: the event streams end, running checks finish.
//!
//! Configuration (environment):
//! PORT listen port (default 3000)
//! ADMIN_KEY key for the admin API (required unless DEV=1)
//! ALLOW_PRIVATE_TARGETS 1 to allow checking loopback/private/link-local addresses
//! (off by default: SSRF protection for the admin API)
//! DEV 1 = insecure demo key and private targets allowed
//!
//! Run: DEV=1 cargo run --example statuspage then open http://localhost:3000
//! Try: curl -s -X POST localhost:3000/api/monitors -H 'x-api-key: dev-admin-key' \
//! -H 'content-type: application/json' \
//! -d '{"name":"This service","target":"http://127.0.0.1:3000/healthz","interval_secs":5}'
//! curl -N localhost:3000/events
async