mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 06:03:27 +00:00
snapshot: make web hosted images bypass hotlink protection
This commit is contained in:
4
plugins/snapshot/package-lock.json
generated
4
plugins/snapshot/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user