mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 14:13:28 +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",
|
"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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user