Skip to content

Commit

Permalink
cloud: support disabling cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Oct 4, 2023
1 parent 1438af8 commit 71cbe83
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugins/cloud/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/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"@types/nat-upnp": "^1.1.2",
"@types/node": "^20.4.5"
},
"version": "0.2.2"
"version": "0.2.3"
}
20 changes: 20 additions & 0 deletions plugins/cloud/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
hide: true,
json: true,
},
cloudflareEnabled: {
group: 'Advanced',
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',
title: 'Cloudflare Tunnel Token',
Expand Down Expand Up @@ -260,6 +268,13 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
// }
// };

this.storageSettings.settings.cloudflaredTunnelToken.onGet =
this.storageSettings.settings.cloudflaredTunnelUrl.onGet = async () => {
return {
hide: !this.storageSettings.values.cloudflareEnabled,
}
};

this.log.clearAlerts();

this.storageSettings.settings.securePort.onPut = (ov, nv) => {
Expand Down Expand Up @@ -839,6 +854,11 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
}

async startCloudflared() {
if (!this.storageSettings.values.cloudflareEnabled) {
this.console.log('cloudflared is disabled.');
return;
}

while (true) {
try {
this.console.log('starting cloudflared');
Expand Down

0 comments on commit 71cbe83

Please sign in to comment.