From 93e3f100067809044b21d539bf1fd62a449031ff Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sun, 24 Jan 2021 18:11:51 -0800 Subject: [PATCH] Server exception fixes. --- meshagent.js | 3 ++- mpsserver.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/meshagent.js b/meshagent.js index 84ae2bfe..972edbb4 100644 --- a/meshagent.js +++ b/meshagent.js @@ -245,7 +245,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { // Send the recovery core to the agent, if the agent is capable of running one if (((obj.agentInfo.capabilities & 16) != 0) && (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core != null)) { obj.agentCoreUpdate = true; - obj.sendBinary(common.ShortToStr(11) + common.ShortToStr(0)); + obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0)); // Ask to clear the core + obj.sendBinary(common.ShortToStr(11) + common.ShortToStr(0)); // Ask for meshcore hash } } else if (agentUpdateMethod === 1) { // Use native agent update system // Mesh agent update required, do it using task limiter so not to flood the network. Medium priority task. diff --git a/mpsserver.js b/mpsserver.js index 1fa55b32..3277696c 100644 --- a/mpsserver.js +++ b/mpsserver.js @@ -616,7 +616,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) { } else { // Node is not in the database, add it. Credentials will be empty until added by the user. var device = { type: 'node', mtype: 1, _id: socket.tag.nodeid, meshid: socket.tag.meshid, name: socket.tag.name, icon: (socket.tag.meiState && socket.tag.meiState.isBatteryPowered) ? 2 : 1, host: socket.remoteAddr, domain: mesh.domain, intelamt: { user: ((socket.tag.meiState) && (typeof socket.tag.meiState.amtuser == 'string')) ? socket.tag.meiState.amtuser : '', pass: ((socket.tag.meiState) && (typeof socket.tag.meiState.amtpass == 'string')) ? socket.tag.meiState.amtpass : '', tls: 0, state: 2 } }; - if ((typeof socket.tag.meiState.desc == 'string') && (socket.tag.meiState.desc.length > 0) && (socket.tag.meiState.desc.length < 1024)) { device.desc = socket.tag.meiState.desc; } + if ((socket.tag.meiState != null) && (typeof socket.tag.meiState.desc == 'string') && (socket.tag.meiState.desc.length > 0) && (socket.tag.meiState.desc.length < 1024)) { device.desc = socket.tag.meiState.desc; } obj.db.Set(device); // Event the new node