From b3a2789a1d5d68b2c2826adbd805c52c79314fe4 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sun, 15 Sep 2024 21:50:33 -0700 Subject: [PATCH] diagnostics: cloud warn --- plugins/diagnostics/package-lock.json | 4 +-- plugins/diagnostics/package.json | 2 +- plugins/diagnostics/src/main.ts | 48 ++++++++++++++------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/plugins/diagnostics/package-lock.json b/plugins/diagnostics/package-lock.json index 48ec3ecf6d..7c5c0036bf 100644 --- a/plugins/diagnostics/package-lock.json +++ b/plugins/diagnostics/package-lock.json @@ -13,7 +13,7 @@ "devDependencies": { "@types/node": "^22.5.4" }, - "version": "0.0.11" + "version": "0.0.12" }, "../../common": { "name": "@scrypted/common", @@ -844,5 +844,5 @@ "dev": true } }, - "version": "0.0.11" + "version": "0.0.12" } diff --git a/plugins/diagnostics/package.json b/plugins/diagnostics/package.json index 9142ee7e2d..6b92a56cd7 100644 --- a/plugins/diagnostics/package.json +++ b/plugins/diagnostics/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/diagnostics", - "version": "0.0.11", + "version": "0.0.12", "scripts": { "scrypted-setup-project": "scrypted-setup-project", "prescrypted-setup-project": "scrypted-package-json", diff --git a/plugins/diagnostics/src/main.ts b/plugins/diagnostics/src/main.ts index ea79f9fb18..cafc0f8f56 100644 --- a/plugins/diagnostics/src/main.ts +++ b/plugins/diagnostics/src/main.ts @@ -309,7 +309,6 @@ class DiagnosticsPlugin extends ScryptedDeviceBase implements Settings { timeout: 5000, }).then(r => r.body.ip)); - await this.validate('IPv4 (wtfismyip.com)', httpFetch({ url: 'https://wtfismyip.com/text', family: 4, @@ -362,34 +361,37 @@ class DiagnosticsPlugin extends ScryptedDeviceBase implements Settings { }); } - if (cloudPlugin) { - await this.validate('Cloud Plugin', async () => { - const logo = await httpFetch({ - url: 'https://home.scrypted.app/_punch/web_hi_res_512.png', - responseType: 'buffer', - }); + await this.validate('Cloud Plugin', async () => { + if (!cloudPlugin) { + this.warnStep('Cloud plugin not installed. Consider installing for remote access.'); + return; + } - const mo = await sdk.mediaManager.createMediaObject(logo.body, 'image/png'); - const url = await sdk.mediaManager.convertMediaObjectToUrl(mo, 'image/png'); + const logo = await httpFetch({ + url: 'https://home.scrypted.app/_punch/web_hi_res_512.png', + responseType: 'buffer', + }); - const logoCheck = await httpFetch({ - url, - responseType: 'buffer', - }); + const mo = await sdk.mediaManager.createMediaObject(logo.body, 'image/png'); + const url = await sdk.mediaManager.convertMediaObjectToUrl(mo, 'image/png'); - if (Buffer.compare(logo.body, logoCheck.body)) - throw new Error('Invalid response received.'); + const logoCheck = await httpFetch({ + url, + responseType: 'buffer', + }); - const shortUrl: any = await sdk.mediaManager.convertMediaObject(mo, ScryptedMimeTypes.Url + ";short-lived=true"); - const shortLogoCheck = await httpFetch({ - url: shortUrl.toString(), - responseType: 'buffer', - }); + if (Buffer.compare(logo.body, logoCheck.body)) + throw new Error('Invalid response received.'); - if (Buffer.compare(logo.body, shortLogoCheck.body)) - throw new Error('Invalid response received from short lived URL.'); + const shortUrl: any = await sdk.mediaManager.convertMediaObject(mo, ScryptedMimeTypes.Url + ";short-lived=true"); + const shortLogoCheck = await httpFetch({ + url: shortUrl.toString(), + responseType: 'buffer', }); - } + + if (Buffer.compare(logo.body, shortLogoCheck.body)) + throw new Error('Invalid response received from short lived URL.'); + }); if (openvinoPlugin) { await this.validate('OpenVINO Plugin', async () => {