cloud: server id reporting

This commit is contained in:
Koushik Dutta
2024-09-20 15:05:56 -07:00
parent ccb7ae0323
commit 3f7b801ffb
6 changed files with 12 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
{
"scrypted.debugHost": "scrypted-server",
"scrypted.debugHost": "scrypted-nvr",
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/cloud",
"version": "0.2.43",
"version": "0.2.44",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/cloud",
"version": "0.2.43",
"version": "0.2.44",
"dependencies": {
"@eneris/push-receiver": "^4.2.0",
"@scrypted/common": "file:../../common",

View File

@@ -53,5 +53,5 @@
"@types/node": "^22.5.2",
"ts-node": "^10.9.2"
},
"version": "0.2.43"
"version": "0.2.44"
}

View File

@@ -258,6 +258,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
this.converters = [
[ScryptedMimeTypes.LocalUrl, ScryptedMimeTypes.Url],
[ScryptedMimeTypes.PushEndpoint, ScryptedMimeTypes.Url],
['*/*', ScryptedMimeTypes.ServerId],
];
// legacy cleanup
this.fromMimeType = undefined;
@@ -723,10 +724,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
}
async convertMedia(data: string | Buffer | any, fromMimeType: string, toMimeType: string, options?: MediaObjectOptions): Promise<MediaObject | Buffer | any> {
if (!toMimeType.startsWith(ScryptedMimeTypes.Url))
throw new Error('unsupported cloud url conversion');
if (fromMimeType.startsWith(ScryptedMimeTypes.LocalUrl)) {
if (toMimeType.startsWith(ScryptedMimeTypes.Url) && fromMimeType.startsWith(ScryptedMimeTypes.LocalUrl)) {
// if cloudflare is enabled and the plugin isn't set up as a custom domain, try to use the cloudflare url for
// short lived urls.
if (this.cloudflareTunnel && this.storageSettings.values.forwardingMode !== 'Custom Domain') {
@@ -740,7 +738,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
}
return this.whitelist(data.toString(), 10 * 365 * 24 * 60 * 60 * 1000, `https://${this.getHostname()}`);
}
else if (fromMimeType.startsWith(ScryptedMimeTypes.PushEndpoint)) {
else if (toMimeType.startsWith(ScryptedMimeTypes.Url) && fromMimeType.startsWith(ScryptedMimeTypes.PushEndpoint)) {
const validDomain = this.getSSLHostname();
if (validDomain)
return Buffer.from(`https://${validDomain}${await this.getCloudMessagePath()}/${data}`);
@@ -748,6 +746,9 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
const url = `http://127.0.0.1/push/${data}`;
return this.whitelist(url, 10 * 365 * 24 * 60 * 60 * 1000, `https://${this.getHostname()}${SCRYPTED_CLOUD_MESSAGE_PATH}`);
}
else if (toMimeType === ScryptedMimeTypes.ServerId) {
return this.storageSettings.values.serverId;
}
throw new Error('unsupported cloud url conversion');
}

View File

@@ -214,6 +214,7 @@ class ScryptedMimeTypes(str, Enum):
RequestMediaObject = "x-scrypted/x-scrypted-request-media-object"
RequestMediaStream = "x-scrypted/x-scrypted-request-stream"
SchemePrefix = "x-scrypted/x-scrypted-scheme-"
ServerId = "text/x-server-id"
Url = "text/x-uri"
class SecuritySystemMode(str, Enum):

View File

@@ -2478,6 +2478,7 @@ export enum ScryptedMimeTypes {
Url = 'text/x-uri',
InsecureLocalUrl = 'text/x-insecure-local-uri',
LocalUrl = 'text/x-local-uri',
ServerId = 'text/x-server-id',
PushEndpoint = 'text/x-push-endpoint',