mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Fixed server exceptions, email alias port.
This commit is contained in:
		
							parent
							
								
									2b32db76bb
								
							
						
					
					
						commit
						e5b7abea40
					
				
					 4 changed files with 14 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -84,6 +84,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
        if (obj.agentUpdate != null) {
 | 
			
		||||
            if (obj.agentUpdate.fd) { try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { } }
 | 
			
		||||
            parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
            delete obj.agentUpdate.buf;
 | 
			
		||||
            delete obj.agentUpdate;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -241,6 +242,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
                                            // Error reading the agent file, stop here.
 | 
			
		||||
                                            try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
 | 
			
		||||
                                            parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
                                            delete obj.agentUpdate.buf;
 | 
			
		||||
                                            delete obj.agentUpdate;
 | 
			
		||||
                                        } else {
 | 
			
		||||
                                            // Send the first block to the agent
 | 
			
		||||
| 
						 | 
				
			
			@ -276,6 +278,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
                                } else {
 | 
			
		||||
                                    // Error
 | 
			
		||||
                                    parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
                                    delete obj.agentUpdate.buf;
 | 
			
		||||
                                    delete obj.agentUpdate;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
| 
						 | 
				
			
			@ -301,6 +304,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
                                    // Error reading the agent file, stop here.
 | 
			
		||||
                                    try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
 | 
			
		||||
                                    parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
                                    delete obj.agentUpdate.buf;
 | 
			
		||||
                                    delete obj.agentUpdate;
 | 
			
		||||
                                } else {
 | 
			
		||||
                                    // Send the next block to the agent
 | 
			
		||||
| 
						 | 
				
			
			@ -312,6 +316,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
                                        obj.send(common.ShortToStr(13) + common.ShortToStr(0) + obj.agentExeInfo.hash); // Command 13, end mesh agent download, send agent SHA384 hash
 | 
			
		||||
                                        try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
 | 
			
		||||
                                        parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
                                        delete obj.agentUpdate.buf;
 | 
			
		||||
                                        delete obj.agentUpdate;
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
| 
						 | 
				
			
			@ -329,6 +334,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
                                //console.log("Agent update sent from RAM.");
 | 
			
		||||
                                obj.send(common.ShortToStr(13) + common.ShortToStr(0) + obj.agentExeInfo.hash); // Command 13, end mesh agent download, send agent SHA384 hash
 | 
			
		||||
                                parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
 | 
			
		||||
                                delete obj.agentUpdate.buf;
 | 
			
		||||
                                delete obj.agentUpdate;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
| 
						 | 
				
			
			@ -513,7 +519,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
 | 
			
		||||
    // Once we get all the information about an agent, run this to hook everything up to the server
 | 
			
		||||
    function completeAgentConnection() {
 | 
			
		||||
        if ((obj.authenticated != 1) || (obj.meshid == null) || obj.pendingCompleteAgentConnection) return;
 | 
			
		||||
        if ((obj.authenticated != 1) || (obj.meshid == null) || obj.pendingCompleteAgentConnection || (obj.agentExeInfo == null)) return;
 | 
			
		||||
        obj.pendingCompleteAgentConnection = true;
 | 
			
		||||
 | 
			
		||||
        // Check if we have too many agent sessions
 | 
			
		||||
| 
						 | 
				
			
			@ -562,6 +568,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
 | 
			
		|||
 | 
			
		||||
        // Check that the node exists
 | 
			
		||||
        db.Get(obj.dbNodeKey, function (err, nodes) {
 | 
			
		||||
            if (obj.agentExeInfo == null) { return; } // Agent has disconnected
 | 
			
		||||
            var device;
 | 
			
		||||
 | 
			
		||||
            // See if this node exists in the database
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1607,7 +1607,7 @@ function InstallModule(modulename, func, tag1, tag2) {
 | 
			
		|||
        console.log('Installing ' + modulename + '...');
 | 
			
		||||
        var child_process = require('child_process');
 | 
			
		||||
        child_process.exec('npm install ' + modulename + ' --no-optional --save', { maxBuffer: 512000 }, function (error, stdout, stderr) {
 | 
			
		||||
            if (error != null) { console.log('ERROR: Unable to install missing package \'' + modulename + '\', make sure npm is installed.'); process.exit(); return; }
 | 
			
		||||
            if (error != null) { console.log('ERROR: Unable to install missing package \'' + modulename + '\', make sure npm is installed: ' + error); process.exit(); return; }
 | 
			
		||||
            func(tag1, tag2);
 | 
			
		||||
            return;
 | 
			
		||||
        });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,12 +102,13 @@ module.exports.CreateMeshMail = function (parent) {
 | 
			
		|||
 | 
			
		||||
    // Perform all e-mail substitution
 | 
			
		||||
    function mailReplacements(text, domain, options) {
 | 
			
		||||
        var httpsport = (typeof obj.parent.args.aliasport == 'number') ? obj.parent.args.aliasport : obj.parent.args.port;
 | 
			
		||||
        if (domain.dns == null) {
 | 
			
		||||
            // Default domain or subdomain of the default.
 | 
			
		||||
            options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + obj.parent.certificates.CommonName + ':' + obj.parent.args.port + domain.url;
 | 
			
		||||
            options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + obj.parent.certificates.CommonName + ':' + httpsport + domain.url;
 | 
			
		||||
        } else {
 | 
			
		||||
            // Domain with a DNS name.
 | 
			
		||||
            options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + domain.dns + ':' + obj.parent.args.port + domain.url;
 | 
			
		||||
            options.serverurl = 'http' + ((obj.parent.args.notls == null) ? 's' : '') + '://' + domain.dns + ':' + httpsport + domain.url;
 | 
			
		||||
        }
 | 
			
		||||
        if (options.serverurl.endsWith('/')) { options.serverurl = options.serverurl.substring(0, options.serverurl.length - 1); } // Remove the ending / if present
 | 
			
		||||
        for (var i in options) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "meshcentral",
 | 
			
		||||
  "version": "0.3.0-b",
 | 
			
		||||
  "version": "0.3.0-c",
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "Remote Management",
 | 
			
		||||
    "Intel AMT",
 | 
			
		||||
| 
						 | 
				
			
			@ -41,6 +41,7 @@
 | 
			
		|||
    "multiparty": "^4.2.1",
 | 
			
		||||
    "nedb": "^1.8.0",
 | 
			
		||||
    "node-forge": "^0.7.6",
 | 
			
		||||
    "nodemailer": "^5.1.1",
 | 
			
		||||
    "otplib": "^10.0.1",
 | 
			
		||||
    "util.promisify": "^1.0.0",
 | 
			
		||||
    "ws": "^6.1.2",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue