Admin geography (#33): offline IP→country + login heatmap (DB-IP Lite, vendored maxminddb) #37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/admin-geoip-33"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lights up the staff-console Geography tab with real login data, looked up in-process against a local
.mmdb— no request-time network, nothing leaves the VPS (ADR-0002).What it does
initGeoIPopens a country.mmdbat boot fromGEOIP_DB; unset/missing ⇒ disabled and harmless (country = "").loginevent tagged with the caller's country.GET /v1/admin/heatmapaggregates those events by country (logins + distinct accounts) for the selected window.X-Forwarded-For— trustworthy here because the server binds127.0.0.1:7421and only Caddy can reach it, so no external caller can spoof it.Why server-side + DB-IP Lite
Chosen over a Caddy-edge lookup because the backend is loopback-only behind the stock apt Caddy (so XFF is trustworthy and we avoid replacing Caddy with a custom
xcaddybuild), and over MaxMind GeoLite2 because DB-IP Lite has no license key / 90-day expiry /geoipupdatesilent-failure risk. The.mmdbis placed on the VPS separately (install-geoipop) and refreshed monthly.No frontend change
admin.html's
vGeoalready calls/v1/admin/heatmapand only falls back to fixtures on error, so registering the endpoint switches Geography to live data automatically.Dependency
github.com/oschwald/maxminddb-golang@v1.12.0, vendored so builds stay hermetic (noproxy.golang.orgat build time). Second exception to stdlib-only aftermodernc.org/sqlite.Tests
geoip_test.go: XFF/RemoteAddr parsing, nil-db safety, name normalisation, and heatmap aggregation (Switzerland {2,2}, Germany {1,1}) + staff-gating.Still pending in #5
The dedicated Funnel tab still needs the small admin.html division guard before
/v1/admin/funnelcan be registered; that's the last piece.