snapshot: make web hosted images bypass hotlink protection

This commit is contained in:
Koushik Dutta
2025-12-27 19:07:50 -08:00
parent ebe6bcc58f
commit 1145caeb58
3 changed files with 8 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/snapshot",
"version": "0.2.66",
"version": "0.2.67",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/snapshot",
"version": "0.2.66",
"version": "0.2.67",
"dependencies": {
"@types/node": "^22.10.2",
"sharp": "^0.33.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/snapshot",
"version": "0.2.66",
"version": "0.2.67",
"description": "Snapshot Plugin for Scrypted",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",

View File

@@ -740,7 +740,7 @@ export class SnapshotPlugin extends AutoenableMixinProvider implements MixinProv
async getLocalSnapshot(id: string, iface: string, search: string) {
const endpoint = await this.authenticatedPath;
const ret = url.resolve(path.join(endpoint, id, iface, `${Date.now()}.jpg`) + `${search}`, '');
const ret = url.resolve(path.join(endpoint, 'hotlink-ok', id, iface, `${Date.now()}.jpg`) + `${search}`, '');
return Buffer.from(ret);
}
@@ -768,7 +768,10 @@ export class SnapshotPlugin extends AutoenableMixinProvider implements MixinProv
return;
}
const pathname = request.url.substring(request.rootPath.length);
let pathname = request.url.substring(request.rootPath.length);
if (pathname.startsWith('/hotlink-ok'))
pathname = pathname.substring('/hotlink-ok'.length);
const [_, id, iface] = pathname.split('/');
try {
if (iface !== ScryptedInterface.Camera && iface !== ScryptedInterface.VideoCamera)