mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
fix(adsbdb): rate-limit /api/adsbdb and cap its enrichment caches
Both keys this route accepts come from the caller — a callsign is 2-8 of [A-Z0-9], a hex is six of [0-9a-f] — and every distinct key that reached upstream was cached, 404s included, with nothing ever removing one. A caller walking the keyspace could therefore drive unlimited live requests at the free community API and grow `.gev-cache/adsbdb.json` without end. Admit 360 requests/minute per client address, global backstop 3x, refusing the rest with 429 and `Retry-After` before any cache, disk or upstream work. The browser cannot exceed 300/min by construction: ENRICH_DISPATCH_GAP_MS is 200 ms, so the enrichment queue drips at most five lookups a second. Hold each store to 20,000 entries, dropping least-recently-written first, and discard entries past the existing 24-hour TTL when the file is read back. A cache file above 16 MB is skipped rather than parsed. Sized from a real session's own file: 397 aircraft entries (~100 B) and 3 route entries (~231 B), so the ceiling is about fifty times an ordinary working set and bounds the file at roughly 7 MB. The two stores become Maps: `size` is O(1), so the ceiling can be enforced on every write, and iteration is true insertion order — an all-digit callsign like "1234" sorts ahead of everything else as an object key. The on-disk JSON shape is unchanged. Refs #261
This commit is contained in:
1 parent
b210ab0fe4
commit
03814d8c47
7 files changed
+362
-18
No files matched your search
@@ -1105,6 +1105,21 @@ The existing aircraft normalizer is separately available through the portable
|
||||
`gods-eye-view/sources/adsb-lol` export. Provider URLs, local credentials, cache
|
||||
policy, fallback behavior, response shapes and rendering remain unchanged.
|
||||
|
||||
### ADSBDB enrichment bounds
|
||||
|
||||
`/api/adsbdb` admits 360 requests/minute per client address, with a global
|
||||
backstop of three times that; a refused request answers 429 with `Retry-After`
|
||||
and reaches neither the cache nor api.adsbdb.com. The browser's own enrichment
|
||||
drip cannot exceed 300/minute, so an ordinary session never meets the limit.
|
||||
|
||||
Both enrichment caches hold at most 20,000 entries each, dropping the
|
||||
least-recently-written first, and entries past their 24-hour TTL are discarded
|
||||
when `.gev-cache/adsbdb.json` is read back. A cache file above 16 MB is skipped
|
||||
rather than parsed. An evicted key costs one upstream request the next time it
|
||||
is asked for; cached answers are otherwise unchanged.
|
||||
|
||||
Updated: September 21, 2026
|
||||
|
||||
## Control names for assistive technology
|
||||
|
||||
Scope, Bloom, Sharpen and location search have explicit accessible names.
|
||||
|
||||
Reference in new issue
Block a user