HTTPS control plane, REST endpoints, real-time telemetry, and JSON metrics schemas.
Every route below is served by the HTTPS server in main/web_ui.cpp on port 443 (using an ECDSA P-256 certificate generated at first boot; plain HTTP port 80 only issues 301 redirects to HTTPS). Every request passes through auth_wrap, which enforces:
/setup and all POST requests receive 403 Forbidden (except /setup itself).sid cookie receive a 303 redirect to /login on GET, or 401 Unauthorized on POST.Cache-Control: no-store, X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: same-origin, and strict Content-Security-Policy.?csrf=<token> in the query string or via the X-CSRF: <token> request header.CLI Scripting: Authenticate via curl, grab the CSRF token, and interact with the endpoints:
curl -k -c cookies.txt -X POST -d 'user=admin&pass=secret' https://esp32adblock.local/login
TOKEN=$(curl -k -b cookies.txt https://esp32adblock.local/ | grep -o "var CSRF='[^']*'" | cut -d"'" -f2)
curl -k -b cookies.txt -H "X-CSRF: $TOKEN" -X POST https://esp32adblock.local/reload
| Method | Path | Description |
|---|---|---|
GET | /setup | First-boot setup wizard: certificate fingerprint and admin credentials creation. |
POST | /setup | Create the initial admin account (opens session, redirects to /setup/network). |
GET | /setup/network | First-boot network setup: Ethernet DHCP/Static and Wi-Fi scan/join. |
GET | /login | Admin authentication sign-in form. |
POST | /login | Verify credentials and issue sid session cookie. 5 failures trigger a 60s lockout. |
POST | /logout | Destroy active session and invalidate cookie. |
GET | / | Main switchboard status dashboard. Polls /metrics every 10s without full page reload. |
GET | /metrics | Raw JSON telemetry, counter states, and latency histograms. |
GET | /metrics/view | Rendered HTML dashboard covering all metrics with auto-refresh. |
POST | /metrics/reset | Reset volatile counters and histograms to zero. |
POST | /reload | Trigger immediate asynchronous blocklist re-download and index rebuild. |
POST | /blocklist/stop | Abort in-progress blocklist download; previous list remains active. |
POST | /pause | Set persistent global sinkhole pause (on=1 allows all traffic, on=0 resumes). |
POST | /pause/timed | Suspend blocking for min minutes (1–1440) for scope=me, scope=host, or scope=all. |
POST | /pause/resume | End an active timed pause early (ip=<IPv4>, ip=all, or ip=every). |
POST | /check | Test domain against live engine: reports BLOCKED, ALLOWED, or REWRITE → ip. |
POST | /whitelist/add | Add a domain to the whitelist (takes effect on the next query). |
POST | /whitelist/remove | Remove a domain from the whitelist. |
POST | /rewrite/set | Define local LAN static rewrite (e.g., printer → 192.168.1.50, up to 48 rules). |
POST | /rewrite/clear | Remove a specific local LAN rewrite entry. |
GET | /log | Recent query log buffer (512-entry ring buffer with UTC timestamps). |
GET | /census | Passive L2 wire census: tracks clients seen via ARP, DHCP, and DNS. |
GET | /top | Top queried/blocked domains and clients with 60-bucket history bar chart. |
POST | /acl/add | Add client IPv4 address to Access Control List. |
POST | /acl/remove | Remove client from ACL. |
POST | /acl/clear | Clear ACL (empty ACL allows all LAN clients). |
POST | /bypass/add | Add client IP to standing bypass list (resolves unfiltered, never cached). |
POST | /dot/set | Configure DNS-over-TLS upstream server address and SNI hostname. |
POST | /ota/update | Upload binary firmware image. Requires valid RSA-3072 signature. |
POST | /reboot | Trigger hardware microcontroller reboot. |
GET /metrics)Returns a compact JSON telemetry document reflecting internal kernel state:
| Field | Type | Description |
|---|---|---|
upstream | string | IP of currently selected upstream resolver. |
uptime_s | int | System uptime in seconds since boot. |
queries_total | int | Total DNS queries received on standard socket paths. |
blocked | int | Total queries sinkholed on socket path. |
forwarded | int | Total queries forwarded to upstream resolver. |
l2_blocked | int | Queries blocked directly in L2 Ethernet frame hook (~1.8ms path). |
l2_cached | int | Forward-cache hits served directly in L2 Ethernet frame hook. |
cache_hit_rate | float | Cache hit percentage (cache_hits / cache_probes * 100). |
blocklist_count | int | Total unique 40-bit domain hashes loaded in PSRAM. |
sd_status | string | MicroSD snapshot status (loaded, saved, absent, etc.). |
heap_free | int | Available internal SRAM bytes. |
psram_free | int | Available external PSRAM bytes. |
latency_us | object | Microsecond percentiles (p50, p99, max) for blocked, cached, and forwarded. |
GET /lastwords)Retrieves the RTC-persisted telemetry buffer recorded immediately before the previous system restart or crash:
{
"available": true,
"reset_reason": "sw",
"queries_total": 48219,
"heap_free_min": 182390,
"queries": [
{ "domain": "ads.example.com", "qtype": 1, "blocked": true, "ts_s": 3812 }
]
}