Fixed server exceptions, email alias port.
Ylian Saint-Hilaire committed
Mar 10, 2019 at 11:00 UTC
e5b7abea4056b4dcc24f50ae257a613c320fa616
4 files changed
+14
-5
meshagent.js
+8
-1
@@ -84,6 +84,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
84
if (obj.agentUpdate != null) {
85
if (obj.agentUpdate.fd) { try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { } }
86
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
87
+ delete obj.agentUpdate.buf;
88
delete obj.agentUpdate;
89
}
90
@@ -241,6 +242,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
242
// Error reading the agent file, stop here.
243
try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
244
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
245
+ delete obj.agentUpdate.buf;
246
delete obj.agentUpdate;
247
} else {
248
// Send the first block to the agent
@@ -276,6 +278,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
278
} else {
279
// Error
280
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
281
+ delete obj.agentUpdate.buf;
282
delete obj.agentUpdate;
283
}
284
}
@@ -301,6 +304,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
304
// Error reading the agent file, stop here.
305
try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
306
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
307
+ delete obj.agentUpdate.buf;
308
delete obj.agentUpdate;
309
} else {
310
// Send the next block to the agent
@@ -312,6 +316,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
316
obj.send(common.ShortToStr(13) + common.ShortToStr(0) + obj.agentExeInfo.hash); // Command 13, end mesh agent download, send agent SHA384 hash
317
try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
318
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
319
+ delete obj.agentUpdate.buf;
320
delete obj.agentUpdate;
321
}
322
}
@@ -329,6 +334,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
334
//console.log("Agent update sent from RAM.");
335
obj.send(common.ShortToStr(13) + common.ShortToStr(0) + obj.agentExeInfo.hash); // Command 13, end mesh agent download, send agent SHA384 hash
336
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
337
+ delete obj.agentUpdate.buf;
338
delete obj.agentUpdate;
339
}
340
}
@@ -513,7 +519,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
519
520
// Once we get all the information about an agent, run this to hook everything up to the server
521
function completeAgentConnection() {
516
- if ((obj.authenticated != 1) || (obj.meshid == null) || obj.pendingCompleteAgentConnection) return;
522
+ if ((obj.authenticated != 1) || (obj.meshid == null) || obj.pendingCompleteAgentConnection || (obj.agentExeInfo == null)) return;
523
obj.pendingCompleteAgentConnection = true;
524
525
// Check if we have too many agent sessions
@@ -562,6 +568,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
568
569
// Check that the node exists
570
db.Get(obj.dbNodeKey, function (err, nodes) {
571
+ if (obj.agentExeInfo == null) { return; } // Agent has disconnected
572
var device;
573
574
// See if this node exists in the database
meshcentral.js
+1
-1
@@ -1607,7 +1607,7 @@ function InstallModule(modulename, func, tag1, tag2) {
1607
console.log('Installing ' + modulename + '...');
1608
var child_process = require('child_process');
1609
child_process.exec('npm install ' + modulename + ' --no-optional --save', { maxBuffer: 512000 }, function (error, stdout, stderr) {
1610
- if (error != null) { console.log('ERROR: Unable to install missing package \'' + modulename + '\', make sure npm is installed.'); process.exit(); return; }
1610
+ if (error != null) { console.log('ERROR: Unable to install missing package \'' + modulename + '\', make sure npm is installed: ' + error); process.exit(); return; }
1611
func(tag1, tag2);
1612
return;
1613
});
meshmail.js
+3
-2
@@ -102,12 +102,13 @@ module.exports.CreateMeshMail = function (parent) {
102
103
// Perform all e-mail substitution
104
function mailReplacements(text, domain, options) {
105
+ var httpsport = (typeof obj.parent.args.aliasport == 'number') ? obj.parent.args.aliasport : obj.parent.args.port;
106
if (domain.dns == null) {
107
// Default domain or subdomain of the default.
107
- options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + obj.parent.certificates.CommonName + ':' + obj.parent.args.port + domain.url;
108
+ options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + obj.parent.certificates.CommonName + ':' + httpsport + domain.url;
109
} else {
110
// Domain with a DNS name.
110
- options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + domain.dns + ':' + obj.parent.args.port + domain.url;
111
+ options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + domain.dns + ':' + httpsport + domain.url;
112
}
113
if (options.serverurl.endsWith('/')) { options.serverurl = options.serverurl.substring(0, options.serverurl.length - 1); } // Remove the ending / if present
114
for (var i in options) {
package.json
+2
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.3.0-b",
3
+ "version": "0.3.0-c",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
@@ -41,6 +41,7 @@
41
"multiparty": "^4.2.1",
42
"nedb": "^1.8.0",
43
"node-forge": "^0.7.6",
44
+ "nodemailer": "^5.1.1",
45
"otplib": "^10.0.1",
46
"util.promisify": "^1.0.0",
47
"ws": "^6.1.2",