Files
meshcore-analyzer/cmd/server
Kpa-clawbot 54a1080e45 feat(known-channels): catalogue cache + /api/known-channels + sidebar (#1323)
GREEN commit. Turns the RED tests green by implementing:

- parseKnownChannelsJSON(): decodes channels-by-country.json shape,
  stamps every entry with its region (ISO 3166-1 alpha-2 lowercase),
  skips empty countries.
- knownChannelsCache: background goroutine fetches the upstream JSON
  every N (default 24h), atomic.Pointer snapshot, fail-soft (last-known
  preserved on upstream 5xx / network error). 30s HTTP timeout, 4 MB
  body cap, custom User-Agent. No DB, no disk cache.
- filterSnapshotByRegion(): copy filter with non-nil empty Entries so
  JSON serialises as [].
- GET /api/known-channels?region=XX: serves the cached snapshot off the
  atomic pointer (never blocks on the upstream).
- main.go: wires the cache (defaults to the pinned upstream URL); empty
  cfg.KnownChannelsURL still gets the default — operators set it empty
  via a different mechanism if they want to disable (future config flag).
- config.example.json: knownChannelsUrl + knownChannelsRefreshMs +
  _comment_knownChannels.
- public/channels.js: new collapsed sidebar section 'Known channels
  (catalogue)' that lazy-fetches /api/known-channels on first render
  and renders rows with a '+ Add' button. Button calls the existing
  addUserChannel(name) path so adding catalogue channels reuses the
  existing key-derive + persist + decrypt flow.

cross-stack: justified — issue #1323 spans cmd/server (cache + route) and
public/channels.js (sidebar surface); same feature, both halves required.
2026-06-11 12:28:05 +00:00
..