Skip to content

Commit

Permalink
diagnostics: cloud warn
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Sep 16, 2024
1 parent fde5cfa commit b3a2789
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions plugins/diagnostics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/diagnostics/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
48 changes: 25 additions & 23 deletions plugins/diagnostics/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit b3a2789

Please sign in to comment.