Fixed meshcore update faliure case.

This commit is contained in:
Ylian Saint-Hilaire 2021-01-28 13:41:19 -08:00
parent 16c2bce40d
commit 29c6b7877e
5 changed files with 7 additions and 5 deletions

View File

@ -4022,7 +4022,7 @@ function agentUpdate_Start(updateurl, updateoptions) {
return;
}
if (sessionid != null) { sendConsoleText('Downloading update...', sessionid); }
if (sessionid != null) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
var options = require('http').parseUri(updateurl != null ? updateurl : require('MeshAgent').ServerUrl);
options.protocol = 'https:';
if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); }
@ -4052,6 +4052,7 @@ function agentUpdate_Start(updateurl, updateoptions) {
agentUpdate_Start._selfupdate.on('error', function (e) {
sendConsoleText('Self Update failed, because there was a problem trying to download the update', sessionid);
sendAgentMessage('Self Update failed, because there was a problem trying to download the update', 3);
agentUpdate_Start._selfupdate = null;
});
agentUpdate_Start._selfupdate.on('response', function (img) {
this._file = require('fs').createWriteStream(agentfilename + '.update', { flags: 'wb' });

View File

@ -399,6 +399,7 @@ function agentUpdate_Start(updateurl, updateoptions)
{
sendConsoleText('Self Update failed, because there was a problem trying to download the update', sessionid);
sendAgentMessage('Self Update failed, because there was a problem trying to download the update', 3);
agentUpdate_Start._selfupdate = null;
});
agentUpdate_Start._selfupdate.on('response', function (img)
{

View File

@ -1179,7 +1179,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
// Add server TLS cert hash
if (parent.parent.args.ignoreagenthashcheck !== true) {
if (isIgnoreHashCheck() == false) {
const tlsCertHash = parent.webCertificateFullHashs[domain.id];
if (tlsCertHash != null) { cmd.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
}
@ -1491,7 +1491,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
// Add server TLS cert hash
if (parent.parent.args.ignoreagenthashcheck !== true) {
if (isIgnoreHashCheck() == false) {
const tlsCertHash = parent.webCertificateFullHashs[domain.id];
if (tlsCertHash != null) { cmd.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
}

View File

@ -1344,7 +1344,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Add server TLS cert hash
var tlsCertHash = null;
if (parent.parent.args.ignoreagenthashcheck !== true) {
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.
tlsCertHash = parent.webCertificateFullHashs[domain.id];
if (tlsCertHash != null) { command.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
}

View File

@ -3432,7 +3432,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Instruct one of more agents to download a URL to a given local drive location.
var tlsCertHash = null;
if (parent.args.ignoreagenthashcheck !== true) {
if ((parent.args.ignoreagenthashcheck == null) || (parent.args.ignoreagenthashcheck === false)) { // TODO: If ignoreagenthashcheck is an array of IP addresses, not sure how to handle this.
tlsCertHash = obj.webCertificateFullHashs[cmd.domain.id];
if (tlsCertHash != null) { tlsCertHash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
}