mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
fix(server): stop track backfill from spending the OpenSky credit budget
`/api/opensky-track` costs 4 OpenSky credits per call against the same ~4000/day account as `/api/opensky`, but participated in none of that proxy's credit governor. Its 60-second per-icao cache bounds memory, not spend: `icao24` is six hex digits, so a caller that varies it produces a fresh key and a fresh upstream call every time. Both track-backfill routes now carry an always-on 30/min per-client limiter (90 global) — the band `/api/geocode` and `/api/regional-brief` already use, and far above the real demand, which is one backfill per aircraft the operator selects. `/api/opensky-track` additionally reads the 429 cooldown `/api/opensky` already maintains. While the account is out of budget it serves any cached track and otherwise answers 429 with the remaining cooldown, instead of minting a token and spending four more credits. adsb.lol is free and unmetered, so only the limiter applies there.
This commit is contained in:
1 parent
b210ab0fe4
commit
65018015a0
7 files changed
+313
-6
No files matched your search
@@ -3843,6 +3843,7 @@ are omitted rather than framing the wrong part of the globe.
|
||||
- `/api/military-installations` uses an independent limiter with the same 90-per-client/300-global one-minute bounds, so viewport installation refreshes never consume `/api/overpass` annotation/traffic capacity.
|
||||
- `/api/route` proxies bounded OSRM route requests for annotation routes, with profile allowlisting, distance caps, response caps, caching, and sanitized "no route found" errors.
|
||||
- Track endpoints: `/api/ais-live/track?mmsi=` (server-accumulated ring buffers; sub-route handled before the rows snapshot), `/api/opensky-track?icao24=` (OAuth, 60s cache, sanitized errors, independent OpenSky credit bucket), `/api/adsblol/trace?hex=` (60s cache, 5MB cap, ODbL attribution required in UI).
|
||||
- Both track-backfill routes carry an always-on per-client limiter of 30 requests/minute (90 global), because their 60s per-key cache bounds memory rather than spend: a caller varying `icao24`/`hex` produces a fresh key and a fresh upstream call each time. `/api/opensky-track` additionally reads `/api/opensky`'s 429 credit cooldown and, while it is active, serves any cached track and otherwise answers `429` with the remaining cooldown instead of spending 4 more credits against an account that is already out of budget.
|
||||
- Realtime debug logs redact API keys, bearer tokens, client secrets, and image data URLs before writing to disk; request bodies are size-capped.
|
||||
- `/api/realtime/debug-log` enforces an always-on 120-per-client/400-global one-minute limiter (not the opt-in `GEV_RATELIMIT_OPENAI_PER_MIN` bucket the cost-bearing OpenAI routes share), appends asynchronously through a serialized queue, and rotates `realtime-conversations.jsonl` at 32 MB keeping one prior generation, so the sink is bounded at twice that regardless of session length. A malformed record answers 400 and a failed write 500, both with a fixed message.
|
||||
|
||||
|
||||
Reference in new issue
Block a user