From c8cc9c0b26a1ef3dd87d325bfde0f1efdb6b8373 Mon Sep 17 00:00:00 2001 From: Denis Groshev Date: Tue, 17 Nov 2026 17:27:59 +0100 Subject: [PATCH] STATION and LIVE register with the panel chrome again; a failed model load is retried; LIVE stops with the briefing collapsed Found by a review of the review fixes: - PanelChrome finds collapsible panels once, at startup, and Context starts closed, so STATION and LIVE inside the Inspector view (mounted only while Context is open) were never registered: their +/- did nothing and their bodies stayed hidden. They sit beside Radio again, always in the page; a test mounts Context closed and finds their collapse buttons. - A model whose load failed was never retried while the station stayed shown (the renderer retries only on an update, and a model not ready is not sent). It is now released 30 s after the failure and asked for again; a model still loading also counts as undrawn out of range. - The Cockpit LIVE page counts as hidden while the briefing card is collapsed, so the player stops there too. - Tests: the label-box gate through the real click handler (it fails on the code before the gate), and the STATION section republishing only when the pose age crosses a whole second. - SECURITY.md: an oversized feed frame closes the socket; the unused import in issCommand.js goes. --- SECURITY.md | 2 +- src/layers/installations/selection.test.mjs | 30 +++++++++++++++++++++ src/layers/satellites/issCommand.js | 2 -- src/layers/satellites/stationModel.js | 22 ++++++++++++++- src/layers/satellites/stationModel.test.mjs | 21 ++++++++++++++- src/layers/satellites/stationPanel.test.mjs | 20 ++++++++++++++ src/ui/contextPanel.test.mjs | 18 +++++++++++++ src/ui/views/ContextView.vue | 7 +++-- src/ui/views/panels/CockpitBriefing.vue | 2 +- 9 files changed, 116 insertions(+), 8 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index ccbcde08cb..db37524e78 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -73,7 +73,7 @@ The data proxies under `server/providers/` are written so the browser cannot tur - **Radio is not an audio relay.** `/api/radio/stations` contacts only allowlisted Radio Browser HTTPS hosts and paths, rejects redirects, rejects any hostname with a loopback/private/link-local/metadata/non-public A or AAAA result, and pins each TLS connection to a validated address. It returns normalized public HTTPS stream URLs; `/api/radio/click/:uuid` applies the same destination policy and accepts only station IDs from the current bounded catalog. The browser then connects directly to the broadcaster after an explicit playback action, so the broadcaster sees the listener's IP address. GEV never proxies, caches, records, or redistributes audio. - **Québec 511 video plays in the browser, opt-in and after Play.** With `CCTV_QUEBEC_VIDEO_ENABLED=1`, `/api/cctv/sources` lists, for each MTQ camera, one URL built server-side from its numeric id on `https://www.quebec511.info/Carte/Fenetres/camera.ashx`; the overlay accepts no other host, path or format. The browser loads that clip only after the viewer presses Play for the selected camera, so Québec 511 sees the viewer's IP address, and the panel says so before Play. Selecting a camera by click, auto-hop, a scene or voice never loads it, and switching cameras stops playback. GEV never proxies, caches or reads the video's pixels. With the flag unset (the default) the browser makes no request to Québec 511. - **Station live video plays only after Play.** The LIVE section of Context and the Cockpit briefing's LIVE page load YouTube's player (the IFrame API from `www.youtube.com`, the video on `www.youtube-nocookie.com`) only after the viewer presses Play, under a line saying that YouTube sees their IP address. Selecting a station by click, a share link that follows it, a scene or voice shows the poster and loads nothing. The player goes when the section is collapsed, Context is closed or collapsed, the Cockpit leaves its LIVE page, the Cockpit is entered or left, or the selection moves to an object without that stream. GEV never proxies, caches or reads the video's pixels. -- **The ISS telemetry relay is opt-in, keyless and read-only.** With `ISS_TELEMETRY_ENABLED=1`, `/api/iss-telemetry` answers from one shared WebSocket the server opens to NASA's public ISSLive feed (`wss://push.lightstreamer.com`), only while a browser has asked in the last two minutes; every byte from the feed is parsed as untrusted text, frames over 64 KB are dropped, and only the listed joint and clock items are kept. The route uses the keyless same-site checks and a per-client rate limit; with the flag unset (the default) it answers `{ configured: false }` and the server opens no socket. +- **The ISS telemetry relay is opt-in, keyless and read-only.** With `ISS_TELEMETRY_ENABLED=1`, `/api/iss-telemetry` answers from one shared WebSocket the server opens to NASA's public ISSLive feed (`wss://push.lightstreamer.com`), only while a browser has asked in the last two minutes; every byte from the feed is parsed as untrusted text, a frame over 64 KB closes the socket (retried on the backoff ladder), and only the listed joint and clock items are kept. The route uses the keyless same-site checks and a per-client rate limit; with the flag unset (the default) it answers `{ configured: false }` and the server opens no socket. - **No verbatim client headers upstream.** The CCTV media route is the one route that relays a request header (`Range`, for video seeking). It is parsed and canonicalized before it is forwarded: one `bytes=` range only, with every accepted form — explicit span, open-ended and suffix — bounded to the same 64 MiB ceiling the relay applies to a declared response body. Multi-range, malformed, inverted and non-`bytes` values are dropped and the request proceeds without a `Range`, as RFC 7233 §3.1 prescribes. Bounding the request bounds what is asked for: a response that declares no length — live streamed media, or a chunked body from an upstream that ignores the `Range` — has no ceiling. An upstream request the browser has stopped waiting for is cancelled rather than left running, whether the viewer leaves before the headers arrive or during the body. - **The Data Library proxy fetches manifest upstreams only.** `/api/library/data/`, `/api/library/tile////` and `/api/library/index/` (a partitioned GeoParquet entry's file index, built from an S3 ListObjectsV2 listing and one ranged footer read per file, cached in memory for the entry's `cacheSeconds`) resolve the id against the validated manifests in `src/library/entries/`; the browser never supplies a URL, and every derived request must stay on the manifest's https host. Redirects are refused, dataset bodies are capped while streaming at the manifest's `maxBytes` (at most 32 MiB) and tiles at 2 MiB of `image/png`, `image/jpeg` or `image/webp`, responses are cached in memory only (at most 512 tiles), requests are rate-limited per client, and upstream error text is never returned. A keyed entry must be proxied; its key is read from this server's environment through the key registry and its routes refuse cross-site and forwarded requests like the other cost-bearing routes. Browser-direct entries are fetched by the browser with no cookies or referrer. - **Transit fetches registered feeds only.** `/api/transit/vehicles/` resolves the id against `src/data/transitFeeds.js`; the browser never supplies a URL, and a feed that is registered but disabled does not resolve at all. Redirects are followed manually and each hop is validated against the feed's own https origin before it is requested, so an off-origin or downgraded hop is refused rather than contacted. Bodies are capped at 8 MB, the protobuf is decoded server-side under entity-count and string-length ceilings, a differential feed is refused, and snapshots live 15 s in memory with no disk cache. A per-feed admission limiter and a failure cooldown ladder bound what this process can ask of any operator. diff --git a/src/layers/installations/selection.test.mjs b/src/layers/installations/selection.test.mjs index ae6cc71fda..07a02a55dd 100644 --- a/src/layers/installations/selection.test.mjs +++ b/src/layers/installations/selection.test.mjs @@ -233,3 +233,33 @@ test('a click on a site dot or its outline selects the site; another set does no h.click({ id: { set: 'other:1', id: outline.id, meta: outline.meta } }); assert.equal(selectedNow(), false); }); + +test('a click on the map itself reads the label box at the click; a click on something drawn there does not', (t) => { + const h = harness(t); + let answer = null; + const asked = []; + h.parts.controls = { + methods: { + findAt(position) { + asked.push(position); + return answer; + }, + }, + }; + // Nothing picked and no label there: the selection is released. + h.click(undefined); + assert.equal(asked.length, 1); + assert.deepEqual(asked[0], { x: 640, y: 400 }, 'in CSS px, where clicked'); + h.assertSelected(false); + // The site's label box at the click selects it. + answer = { id: 'base' }; + h.click(undefined); + assert.equal(asked.length, 2); + h.assertSelected(true); + // Something else drawn under the click (an aircraft, a vessel): the label + // box is not read, and the site's selection is released as for any other + // contact. + h.click({ id: 'flight:abc123' }); + assert.equal(asked.length, 2, 'the label box is not asked'); + h.assertSelected(false); +}); diff --git a/src/layers/satellites/issCommand.js b/src/layers/satellites/issCommand.js index 3b2bdd0aa1..3cfec6b081 100644 --- a/src/layers/satellites/issCommand.js +++ b/src/layers/satellites/issCommand.js @@ -1,5 +1,3 @@ -import { t } from '../../i18n/index.js'; - const unit = (v) => { const n = Math.hypot(...v); return v.map((c) => c / n); diff --git a/src/layers/satellites/stationModel.js b/src/layers/satellites/stationModel.js index aaff5901ca..f02a4fa38f 100644 --- a/src/layers/satellites/stationModel.js +++ b/src/layers/satellites/stationModel.js @@ -67,10 +67,18 @@ import { stationTrackedOn } from './policy.js'; * @property {number} [unloadAfterMs] How long the model may go undrawn (out * of range, or hidden) before its draw set is released and its GPU memory * with it; asked for again on the next approach. Default one minute. + * @property {number} [retryAfterMs] How long after a failed load the model + * is released and asked for again. Default 30 s. */ /** Default `unloadAfterMs`: a minute undrawn releases the model. */ export const STATION_MODEL_UNLOAD_AFTER_MS = 60_000; +/** + * A model that failed to load is released after this and asked for again + * on the next frame in range (the renderer retries a load only on an + * update, and a model that is not ready is not sent). + */ +export const STATION_MODEL_RETRY_AFTER_MS = 30_000; /** * Whether a station model may be drawn: the dot's own rules (layer on, points @@ -229,6 +237,8 @@ export function createStationModel( let ready = false; let loading = false; let failed = false; + /** When the renderer said the load failed (wall-clock ms), or null. */ + let failedAt = null; /** Turns the moving parts by where the Sun (and the relays) are. */ const articulation = spec.createArticulation(); /** Where the joint driver writes; kept for a renderer that poses nodes. */ @@ -315,8 +325,9 @@ export function createStationModel( offFailed = set.on('loadFailed', (id, message) => { if (id !== itemId) return; // The dots keep drawing at every distance (the model is never ready); - // the next approach after the model is released tries again. + // after `retryAfterMs` the model is released and asked for again. failed = true; + failedAt = Date.now(); loading = false; console.warn( `[Data:Satellites] ${spec.label} model failed to load:`, @@ -668,6 +679,14 @@ export function createStationModel( if (handedCompanions.size) _releaseCompanions(); handingOver = false; _syncOrbitCloseUp(false); + if ( + failedAt !== null && + Date.now() - failedAt >= + (spec.retryAfterMs ?? STATION_MODEL_RETRY_AFTER_MS) + ) + _unload(); // asked for again on the next frame in range + else if (cameraDistance > spec.maxDistanceM * 1.5) _undrawn(); + else undrawnSince = null; return; } // The docked dots are the model's within its range: handed over at @@ -769,6 +788,7 @@ export function createStationModel( handingOver = false; loading = false; failed = false; + failedAt = null; ready = false; visualValid = false; undrawnSince = null; diff --git a/src/layers/satellites/stationModel.test.mjs b/src/layers/satellites/stationModel.test.mjs index 556a3baab2..5884f79074 100644 --- a/src/layers/satellites/stationModel.test.mjs +++ b/src/layers/satellites/stationModel.test.mjs @@ -336,7 +336,14 @@ test('until the renderer has the model the dots stand at every distance, and sta assert.equal(f.drawn(STATION).displayRange, undefined); assert.equal(f.drawn(COMPANION).displayRange, undefined); assert.equal(f.trackedDot().displayRange, undefined); - // A load that does finish hands them over. + // After the retry delay the model is released, and the next frame asks + // for it again: one transient failure does not cost the session. + f.model.spec.retryAfterMs = 0; + f.tick(); + assert.equal(f.modelSet(), undefined, 'released after a failure'); + f.tick(); + assert.ok(f.modelItem(), 'asked for again'); + // That load finishes: the dots are handed over. f.readyModel(); f.tick(); assert.equal(f.modelItem().show, true); @@ -344,6 +351,18 @@ test('until the renderer has the model the dots stand at every distance, and sta assert.deepEqual(f.trackedDot().displayRange, FAR_RANGE); }); +test('a model still loading counts as undrawn out of range and is released', (t) => { + const f = fixture(t); + f.cameraAt(MAX_M * 1.4); + f.tick(); // asks for the model, which never answers + f.cameraAt(MAX_M * 5); + f.tick(); + assert.ok(f.modelSet(), 'kept for a while'); + f.model.spec.unloadAfterMs = 0; + f.tick(); + assert.equal(f.modelSet(), undefined); +}); + test('turning the layer off, or a while undrawn, releases the model; the next approach asks for it again', async (t) => { const f = fixture(t); await f.load(); diff --git a/src/layers/satellites/stationPanel.test.mjs b/src/layers/satellites/stationPanel.test.mjs index 7209aaba16..faf0075402 100644 --- a/src/layers/satellites/stationPanel.test.mjs +++ b/src/layers/satellites/stationPanel.test.mjs @@ -348,3 +348,23 @@ test('actions without a station are refused; destroy publishes nothing', () => { f.panel._destroyStationPanel(); assert.equal(f.view(), null); }); + +test('frame after frame, the section is republished only when the age crosses a whole second', (t) => { + const f = fixture(); + t.after(() => f.panel._destroyStationPanel()); + f.select(true); + f.setTelemetry({ state: 'live', poseAgeMs: 3010, liveUntilMs: null }); + f.panel._syncStationPanel(); + const published = f.views.length; + assert.equal(f.view().telemetry.poseAgeMs, 3000, 'in whole seconds'); + // The tick runs every frame; the age moves by milliseconds. + for (const age of [3020, 3150, 3600, 3999]) { + f.setTelemetry({ state: 'live', poseAgeMs: age, liveUntilMs: null }); + f.panel._syncStationPanel(); + } + assert.equal(f.views.length, published, 'nothing new to show'); + f.setTelemetry({ state: 'live', poseAgeMs: 4001, liveUntilMs: null }); + f.panel._syncStationPanel(); + assert.equal(f.views.length, published + 1); + assert.equal(f.view().telemetry.poseAgeMs, 4000); +}); diff --git a/src/ui/contextPanel.test.mjs b/src/ui/contextPanel.test.mjs index 8de52cbb21..3fc28260f3 100644 --- a/src/ui/contextPanel.test.mjs +++ b/src/ui/contextPanel.test.mjs @@ -171,3 +171,21 @@ test('the nearby sites search is busy, without native disable, until it settles' assert.equal(button.getAttribute('aria-busy'), 'false'); assert.equal(button.getAttribute('aria-disabled'), 'false'); }); + +test('with Context closed, the collapsible sections are already in the page for PanelChrome', (t) => { + // PanelChrome finds collapsible panels once, at startup, by their collapse + // buttons; Context starts closed, so a section that mounts only while it + // is open would never be registered and its +/- would do nothing. + fixture(t); + assert.equal( + document + .getElementById('global-context-panel') + .classList.contains('collapsed'), + true, + ); + const targets = [ + ...document.querySelectorAll('.panel-collapse-btn[data-collapse-target]'), + ].map((button) => button.dataset.collapseTarget); + for (const id of ['station-panel', 'live-panel', 'radio-panel']) + assert.ok(targets.includes(id), `${id} is there to be registered`); +}); diff --git a/src/ui/views/ContextView.vue b/src/ui/views/ContextView.vue index b2e268c41f..dbda26983e 100644 --- a/src/ui/views/ContextView.vue +++ b/src/ui/views/ContextView.vue @@ -217,6 +217,11 @@ watch(
+ + +
diff --git a/src/ui/views/panels/CockpitBriefing.vue b/src/ui/views/panels/CockpitBriefing.vue index d0d16bfbe3..34a3ec6581 100644 --- a/src/ui/views/panels/CockpitBriefing.vue +++ b/src/ui/views/panels/CockpitBriefing.vue @@ -85,7 +85,7 @@ function leaveSignals() { {{ t('Weather data by Open-Meteo.com') }}
- +