mirror of
https://github.com/koush/scrypted.git
synced 2026-05-04 21:30:30 +01:00
cloud: earlier unregistration fix for cloudflare
This commit is contained in:
4
plugins/cloud/package-lock.json
generated
4
plugins/cloud/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/cloud",
|
||||
"version": "0.2.21",
|
||||
"version": "0.2.22",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/cloud",
|
||||
"version": "0.2.21",
|
||||
"version": "0.2.22",
|
||||
"dependencies": {
|
||||
"@eneris/push-receiver": "^3.1.5",
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -53,5 +53,5 @@
|
||||
"@types/nat-upnp": "^1.1.5",
|
||||
"@types/node": "^20.14.6"
|
||||
},
|
||||
"version": "0.2.21"
|
||||
"version": "0.2.22"
|
||||
}
|
||||
|
||||
@@ -1012,14 +1012,14 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
|
||||
|
||||
const deferred = new Deferred<string>();
|
||||
const cloudflareTunnel = cloudflared.tunnel(args);
|
||||
cloudflareTunnel.child.stdout.on('data', data => this.console.log(data.toString()));
|
||||
cloudflareTunnel.child.stderr.on('data', data => {
|
||||
|
||||
const processData = (data: string) => {
|
||||
const string: string = data.toString();
|
||||
this.console.error(string);
|
||||
|
||||
const lines = string.split('\n');
|
||||
for (const line of lines) {
|
||||
if (line.includes('Register tunnel error') && deferred.finished ) {
|
||||
if (line.includes('Unregistered tunnel connection') && deferred.finished) {
|
||||
this.console.warn('Cloudflare registration failed after tunnel started. The old tunnel may be invalid. Terminating.');
|
||||
cloudflareTunnel.child.kill();
|
||||
}
|
||||
@@ -1044,7 +1044,19 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cloudflareTunnel.child.stdout.on('data', data => {
|
||||
const d = data.toString();
|
||||
this.console.log(d);
|
||||
processData(d);
|
||||
});
|
||||
cloudflareTunnel.child.stderr.on('data', data => {
|
||||
const d = data.toString();
|
||||
this.console.error(d);
|
||||
processData(d);
|
||||
});
|
||||
|
||||
cloudflareTunnel.child.on('exit', () => deferred.resolve(undefined));
|
||||
try {
|
||||
this.cloudflareTunnel = await Promise.any([deferred.promise, cloudflareTunnel.url]);
|
||||
|
||||
Reference in New Issue
Block a user