mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
ugh
This commit is contained in:
@@ -74,18 +74,28 @@ app.post('/mediamtx/auth', (req, res) => {
|
|||||||
const body = req.body || {};
|
const body = req.body || {};
|
||||||
const path = (body.path || '').replace(/^\//, '');
|
const path = (body.path || '').replace(/^\//, '');
|
||||||
const sessionId = body.user;
|
const sessionId = body.user;
|
||||||
const action = body.action || '';
|
const action = (body.action || '').toLowerCase();
|
||||||
const protocol = body.protocol || '';
|
const protocol = (body.protocol || '').toLowerCase();
|
||||||
const ip = body.ip || req.ip || '';
|
const ip = body.ip || req.ip || '';
|
||||||
const streamInfo = extractStreamInfo(path);
|
const streamInfo = extractStreamInfo(path);
|
||||||
|
|
||||||
logger.info('video auth request', { path: body.path, sessionId, stream: streamInfo, action, protocol, ip });
|
logger.info('video auth request', { path: body.path, sessionId, stream: streamInfo, action, protocol, ip });
|
||||||
|
|
||||||
|
const normalizedIp = (() => {
|
||||||
|
if (!ip) return '';
|
||||||
|
if (ip.includes('::ffff:')) {
|
||||||
|
return ip.replace(/^::ffff:/, '');
|
||||||
|
}
|
||||||
|
if (ip.includes('.') && ip.includes(':')) {
|
||||||
|
return ip.slice(0, ip.lastIndexOf(':'));
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
})();
|
||||||
const isLocal =
|
const isLocal =
|
||||||
ip === '127.0.0.1' ||
|
normalizedIp === '127.0.0.1' ||
|
||||||
ip === '::1' ||
|
normalizedIp === '::1' ||
|
||||||
ip === '::ffff:127.0.0.1';
|
normalizedIp === 'localhost';
|
||||||
if (!sessionId && action === 'read' && protocol === 'srt' && isLocal && streamInfo?.id) {
|
if (action === 'read' && protocol === 'srt' && streamInfo?.id && (isLocal || !normalizedIp)) {
|
||||||
return res.status(200).end();
|
return res.status(200).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user