diff --git a/db.js b/db.js index d51467c3..462eb788 100644 --- a/db.js +++ b/db.js @@ -1901,7 +1901,7 @@ module.exports.CreateDB = function (parent, func) { // Perform pending operations obj.dbCounters.eventsSetBulk++; var ops = []; - for (var i in obj.eventsFilePendingSets) { ops.push({ document: obj.eventsFilePendingSets[i] }); } + for (var i in obj.eventsFilePendingSets) { ops.push({ insertOne: { document: obj.eventsFilePendingSets[i] } }); } obj.eventsFilePendingCbs = obj.eventsFilePendingCb; obj.eventsFilePendingCb = null; obj.eventsFilePendingSets = null; @@ -1920,7 +1920,7 @@ module.exports.CreateDB = function (parent, func) { // Perform pending operations obj.dbCounters.powerSetBulk++; var ops = []; - for (var i in obj.powerFilePendingSets) { ops.push({ document: obj.powerFilePendingSets[i] }); } + for (var i in obj.powerFilePendingSets) { ops.push({ insertOne: { document: obj.powerFilePendingSets[i] } }); } obj.powerFilePendingCbs = obj.powerFilePendingCb; obj.powerFilePendingCb = null; obj.powerFilePendingSets = null; diff --git a/meshagent.js b/meshagent.js index b9a75cba..27d8f06f 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1481,8 +1481,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { // TODO: This this extra stats from the tunnel, you can merge this into the tunnel event in the database. //console.log(command); + // Validate input + if ((command.sent == null) || (typeof command.sent != 'string')) return; + if ((command.sentActual == null) || (typeof command.sentActual != 'string')) return; + if ((command.sentActual == null) || (typeof command.sentActual != 'number')) return; + // Event the session closed compression data. - var event = { etype: 'node', action: 'sessioncompression', nodeid: obj.dbNodeKey, domain: domain.id, sent: command.sent, sentActual: command.sentActual, msgid: 54, msgArgs: [command.sentRatio, command.sent, command.sentActual], msg: 'Agent closed session with ' + command.sentRatio + '% agent to server compression. Sent: ' + command.sent + ', Compressed: ' + command.sentActual + '.' }; + var event = { etype: 'node', action: 'sessioncompression', nodeid: obj.dbNodeKey, domain: domain.id, sent: parseInt(command.sent), sentActual: parseInt(command.sentActual), msgid: 54, msgArgs: [command.sentRatio, parseInt(command.sent), parseInt(command.sentActual)], msg: 'Agent closed session with ' + command.sentRatio + '% agent to server compression. Sent: ' + command.sent + ', Compressed: ' + command.sentActual + '.' }; parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, event); break; }