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", "name": "@scrypted/snapshot",
"version": "0.2.66", "version": "0.2.67",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@scrypted/snapshot", "name": "@scrypted/snapshot",
"version": "0.2.66", "version": "0.2.67",
"dependencies": { "dependencies": {
"@types/node": "^22.10.2", "@types/node": "^22.10.2",
"sharp": "^0.33.5", "sharp": "^0.33.5",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@scrypted/snapshot", "name": "@scrypted/snapshot",
"version": "0.2.66", "version": "0.2.67",
"description": "Snapshot Plugin for Scrypted", "description": "Snapshot Plugin for Scrypted",
"scripts": { "scripts": {
"scrypted-setup-project": "scrypted-setup-project", "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) { async getLocalSnapshot(id: string, iface: string, search: string) {
const endpoint = await this.authenticatedPath; 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); return Buffer.from(ret);
} }
@@ -768,7 +768,10 @@ export class SnapshotPlugin extends AutoenableMixinProvider implements MixinProv
return; 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('/'); const [_, id, iface] = pathname.split('/');
try { try {
if (iface !== ScryptedInterface.Camera && iface !== ScryptedInterface.VideoCamera) if (iface !== ScryptedInterface.Camera && iface !== ScryptedInterface.VideoCamera)