Skip to content

Commit

Permalink
cloud: send server id and friendly name
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Feb 23, 2024
1 parent 3a6b244 commit a05bcd6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
15 changes: 7 additions & 8 deletions plugins/cloud/package-lock.json

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

4 changes: 2 additions & 2 deletions plugins/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",
"bpmux": "^8.2.1",
"cloudflared": "^0.5.1",
"cloudflared": "^0.4.0",
"exponential-backoff": "^3.1.1",
"http-proxy": "^1.18.1",
"nat-upnp": "file:./external/node-nat-upnp"
Expand All @@ -53,5 +53,5 @@
"@types/nat-upnp": "^1.1.5",
"@types/node": "^20.11.19"
},
"version": "0.2.6"
"version": "0.2.7"
}
22 changes: 15 additions & 7 deletions plugins/cloud/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,36 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
json: true,
},
cloudflareEnabled: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare',
type: 'boolean',
description: 'Optional: Create a Cloudflare Tunnel to this server at a random domain name. Providing a Cloudflare token will allow usage of a custom domain name.',
defaultValue: true,
onPut: () => deviceManager.requestRestart(),
},
cloudflaredTunnelToken: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare Tunnel Token',
description: 'Optional: Enter the Cloudflare token from the Cloudflare Dashbaord to track and manage the tunnel remotely.',
onPut: () => {
this.cloudflared?.child.kill();
},
},
cloudflaredTunnelUrl: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare Tunnel URL',
description: 'Cloudflare Tunnel URL is a randomized cloud connection, unless a Cloudflare Tunnel Token is provided.',
readonly: true,
mapGet: () => this.cloudflareTunnel || 'Unavailable',
},
serverName: {
group: 'Connection',
title: 'Server Name',
description: 'The name of this server. This is used to identify this server in the Scrypted Cloud.',
persistedDefaultValue: os.hostname()?.split('.')[0] || 'Scrypted Server',
},
register: {
group: 'Advanced',
group: 'Connection',
title: 'Register',
type: 'button',
onPut: () => {
Expand All @@ -187,7 +193,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
description: 'Register server with Scrypted Cloud.',
},
testPortForward: {
group: 'Advanced',
group: 'Connection',
title: 'Test Port Forward',
type: 'button',
onPut: () => this.testPortForward(),
Expand Down Expand Up @@ -246,7 +252,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,

this.storageSettings.settings.securePort.onGet = async () => {
return {
group: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Advanced' : undefined,
group: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Cloudflare' : undefined,
title: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Cloudflare Port' : 'Forward Port',
}
};
Expand Down Expand Up @@ -582,6 +588,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
upnp_port,
registration_id,
server_id: this.storageSettings.values.serverId,
server_name: this.storageSettings.values.serverName,
sender_id: DEFAULT_SENDER_ID,
registration_secret,
hostname,
Expand Down Expand Up @@ -705,8 +712,9 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,

async getOauthUrl(): Promise<string> {
const args = qsstringify({
hostname: os.hostname(),
registration_id: await this.manager.registrationId,
server_id: this.storageSettings.values.serverId,
server_name: this.storageSettings.values.serverName,
sender_id: DEFAULT_SENDER_ID,
redirect_uri: `https://${SCRYPTED_SERVER}/web/oauth/callback`,
})
Expand Down

0 comments on commit a05bcd6

Please sign in to comment.