Fixed meshcore update faliure case.

Ylian Saint-Hilaire committed Jan 28, 2021 at 13:41 UTC 29c6b7877eda1c3a3e243ce20ada7cfdd30b24e5
5 files changed +7 -5
agents/meshcore.js
+2 -1
@@ -4022,7 +4022,7 @@ function agentUpdate_Start(updateurl, updateoptions) {
4022 return;
4023 }
4024
4025 - if (sessionid != null) { sendConsoleText('Downloading update...', sessionid); }
4025 + if (sessionid != null) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
4026 var options = require('http').parseUri(updateurl != null ? updateurl : require('MeshAgent').ServerUrl);
4027 options.protocol = 'https:';
4028 if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); }
@@ -4052,6 +4052,7 @@ function agentUpdate_Start(updateurl, updateoptions) {
4052 agentUpdate_Start._selfupdate.on('error', function (e) {
4053 sendConsoleText('Self Update failed, because there was a problem trying to download the update', sessionid);
4054 sendAgentMessage('Self Update failed, because there was a problem trying to download the update', 3);
4055 + agentUpdate_Start._selfupdate = null;
4056 });
4057 agentUpdate_Start._selfupdate.on('response', function (img) {
4058 this._file = require('fs').createWriteStream(agentfilename + '.update', { flags: 'wb' });
agents/recoverycore.js
+1
@@ -399,6 +399,7 @@ function agentUpdate_Start(updateurl, updateoptions)
399 {
400 sendConsoleText('Self Update failed, because there was a problem trying to download the update', sessionid);
401 sendAgentMessage('Self Update failed, because there was a problem trying to download the update', 3);
402 + agentUpdate_Start._selfupdate = null;
403 });
404 agentUpdate_Start._selfupdate.on('response', function (img)
405 {
meshagent.js
+2 -2
@@ -1179,7 +1179,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1179 if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
1180
1181 // Add server TLS cert hash
1182 - if (parent.parent.args.ignoreagenthashcheck !== true) {
1182 + if (isIgnoreHashCheck() == false) {
1183 const tlsCertHash = parent.webCertificateFullHashs[domain.id];
1184 if (tlsCertHash != null) { cmd.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
1185 }
@@ -1491,7 +1491,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1491 if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
1492
1493 // Add server TLS cert hash
1494 - if (parent.parent.args.ignoreagenthashcheck !== true) {
1494 + if (isIgnoreHashCheck() == false) {
1495 const tlsCertHash = parent.webCertificateFullHashs[domain.id];
1496 if (tlsCertHash != null) { cmd.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
1497 }
meshuser.js
+1 -1
@@ -1344,7 +1344,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1344
1345 // Add server TLS cert hash
1346 var tlsCertHash = null;
1347 - if (parent.parent.args.ignoreagenthashcheck !== true) {
1347 + if ((parent.parent.args.ignoreagenthashcheck == null) || (parent.parent.args.ignoreagenthashcheck === false)) { // TODO: If ignoreagenthashcheck is an array of IP addresses, not sure how to handle this.
1348 tlsCertHash = parent.webCertificateFullHashs[domain.id];
1349 if (tlsCertHash != null) { command.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
1350 }
webserver.js
+1 -1
@@ -3432,7 +3432,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3432
3433 // Instruct one of more agents to download a URL to a given local drive location.
3434 var tlsCertHash = null;
3435 - if (parent.args.ignoreagenthashcheck !== true) {
3435 + if ((parent.args.ignoreagenthashcheck == null) || (parent.args.ignoreagenthashcheck === false)) { // TODO: If ignoreagenthashcheck is an array of IP addresses, not sure how to handle this.
3436 tlsCertHash = obj.webCertificateFullHashs[cmd.domain.id];
3437 if (tlsCertHash != null) { tlsCertHash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
3438 }