mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
fix(cctv): keep main's HLS leases and test them through the middleware
Drop the per-peer lease budget and the lease-to-address binding. Main's keyless same-site gate already refuses cross-site media requests, while the budget capped a shared address (Docker gateway, reverse proxy, NAT) at 8 leases across both sessions and still let one address hold both. A lease now keeps working when its viewer reconnects from a new address. Add a middleware test that drives the HLS playlist, segment and DELETE for viewers on one shared address, on distinct addresses and after an address change, and fold the media cases (segment read, DELETE, no catalog request) into the cross-site table test. Remove the redundant puppeteer flag, the CURRENT-STATE paragraph and the changelog fragment, which no longer describe a change.
This commit is contained in:
1 parent
90e464eb5a
commit
0699876e4e
8 files changed
+212
-162
No files matched your search
@@ -264,10 +264,6 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
||||
// keyless gate keeps the routes reachable behind a reverse proxy; the
|
||||
// key-bearing Street View fallback below has its own check.
|
||||
if (admitSameSiteKeyless(req, res)) return;
|
||||
const clientId = String(req.socket?.remoteAddress || 'unknown').replace(
|
||||
/^::ffff:/,
|
||||
'',
|
||||
);
|
||||
const sources = await getCctvSources();
|
||||
const sourceById = new Map(
|
||||
sources.map((source) => [source.id, source]),
|
||||
@@ -379,7 +375,7 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
||||
return;
|
||||
}
|
||||
if (req.method === 'DELETE') {
|
||||
if (leaseId) puller.release(cameraId, leaseId, clientId);
|
||||
if (leaseId) puller.release(cameraId, leaseId);
|
||||
res.writeHead(204);
|
||||
res.end();
|
||||
return;
|
||||
@@ -409,7 +405,6 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
||||
url.searchParams.get('session'),
|
||||
Number(match[3]),
|
||||
leaseId,
|
||||
clientId,
|
||||
);
|
||||
res.writeHead(body ? 200 : 404, {
|
||||
'Content-Type': 'video/mp2t',
|
||||
@@ -421,15 +416,10 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
||||
const downstream = watchDownstreamClose(res);
|
||||
let entry;
|
||||
const cancelPending = () => {
|
||||
if (entry) puller.release(cameraId, leaseId, clientId);
|
||||
if (entry) puller.release(cameraId, leaseId);
|
||||
};
|
||||
try {
|
||||
entry = await puller.ensure(
|
||||
cameraId,
|
||||
mediaUrl,
|
||||
leaseId,
|
||||
clientId,
|
||||
);
|
||||
entry = await puller.ensure(cameraId, mediaUrl, leaseId);
|
||||
if (downstream.closed) {
|
||||
cancelPending();
|
||||
return;
|
||||
@@ -443,7 +433,6 @@ export function cctvProxy({ sourceRoot = process.cwd() } = {}) {
|
||||
entry,
|
||||
cameraId,
|
||||
leaseId,
|
||||
clientId,
|
||||
);
|
||||
if (downstream.closed) return;
|
||||
if (!playlist) throw new Error('Stream unavailable');
|
||||
|
||||
Reference in new issue
Block a user