mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Server fixes
This commit is contained in:
		
							parent
							
								
									73fed8b379
								
							
						
					
					
						commit
						cd9a854090
					
				
					 6 changed files with 33 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -949,6 +949,23 @@ function createMeshCore(agent) {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Delete a directory with a files and directories within it
 | 
			
		||||
    function deleteFolderRecursive(path, rec) {
 | 
			
		||||
        if (fs.existsSync(path)) {
 | 
			
		||||
            if (rec == true) {
 | 
			
		||||
                fs.readdirSync(obj.path.join(path, '*')).forEach(function (file, index) {
 | 
			
		||||
                    var curPath = obj.path.join(path, file);
 | 
			
		||||
                    if (fs.statSync(curPath).isDirectory()) { // recurse
 | 
			
		||||
                        deleteFolderRecursive(curPath, true);
 | 
			
		||||
                    } else { // delete file
 | 
			
		||||
                        fs.unlinkSync(curPath);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            fs.unlinkSync(path);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // Called when receiving control data on WebRTC
 | 
			
		||||
    function onTunnelWebRTCControlData(data) {
 | 
			
		||||
        if (typeof data != 'string') return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								agents/meshcore.min.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								agents/meshcore.min.js
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -154,7 +154,7 @@ module.exports.CertificateOperations = function (parent) {
 | 
			
		|||
        if (extKeyUsage == null) { extKeyUsage = { name: "extKeyUsage", serverAuth: true }; } else { extKeyUsage.name = "extKeyUsage"; }
 | 
			
		||||
        //var extensions = [{ name: "basicConstraints", cA: false }, { name: "keyUsage", keyCertSign: true, digitalSignature: true, nonRepudiation: true, keyEncipherment: true, dataEncipherment: true }, extKeyUsage, { name: "nsCertType", client: false, server: true, email: false, objsign: false, sslCA: false, emailCA: false, objCA: false }, { name: "subjectKeyIdentifier" }];
 | 
			
		||||
        var extensions = [{ name: "basicConstraints", cA: false }, { name: "keyUsage", keyCertSign: false, digitalSignature: true, nonRepudiation: false, keyEncipherment: true, dataEncipherment: (extKeyUsage.serverAuth !== true) }, extKeyUsage, { name: "subjectKeyIdentifier" }];
 | 
			
		||||
        if (extKeyUsage.serverAuth === true) { extensions.push({ name: "subjectAltName", altNames: [{ type: 6, value: "http://" + commonName + "/" }, { type: 6, value: "http://localhost/" }] }); }
 | 
			
		||||
        if (extKeyUsage.serverAuth === true) { extensions.push({ name: "subjectAltName", altNames: [{ type: 6, value: "http://" + commonName + "/" }, { type: 6, value: "http://localhost/" }, { type: 6, value: commonName }, { type: 6, value: "localhost" }] }); }
 | 
			
		||||
 | 
			
		||||
        cert.setExtensions(extensions);
 | 
			
		||||
        cert.sign(rootcert.key, obj.forge.md.sha384.create());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -517,12 +517,12 @@ function CreateMeshCentralServer(config, args) {
 | 
			
		|||
            var info = process.memoryUsage(), txt = [];
 | 
			
		||||
            info.time = Date.now();
 | 
			
		||||
            for (var i in info) { txt.push(i); }
 | 
			
		||||
            obj.fs.appendFile(obj.getConfigFilePath('memorytracking.txt'), txt.join(',') + '\r\n', function (err) { });
 | 
			
		||||
            obj.fs.appendFile(obj.getConfigFilePath('memorytracking.csv'), txt.join(',') + '\r\n', function (err) { });
 | 
			
		||||
            setInterval(function () {
 | 
			
		||||
                var info = process.memoryUsage(), txt = [];
 | 
			
		||||
                info.time = Date.now();
 | 
			
		||||
                for (var i in info) { txt.push(info[i]); }
 | 
			
		||||
                obj.fs.appendFile(obj.getConfigFilePath('memorytracking.txt'), txt.join(',') + '\r\n', function (err) { });
 | 
			
		||||
                obj.fs.appendFile(obj.getConfigFilePath('memorytracking.csv'), txt.join(',') + '\r\n', function (err) { });
 | 
			
		||||
            }, (obj.args.memorytracking * 1000));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4124,6 +4124,7 @@
 | 
			
		|||
            QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (deskState != 0) && (desktopsettings.showfocus));
 | 
			
		||||
            QV('DeskCAD', inputAllowed);
 | 
			
		||||
            QE('DeskCAD', deskState == 3);
 | 
			
		||||
            //QV('DeskClip', (desktop != null) && (desktop.contype == 1));
 | 
			
		||||
            QE('DeskClip', deskState == 3);
 | 
			
		||||
            QV('DeskWD', (currentNode.agent) && (currentNode.agent.id < 5) && inputAllowed);
 | 
			
		||||
            QE('DeskWD', deskState == 3);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										11
									
								
								webserver.js
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								webserver.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -131,6 +131,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
 | 
			
		|||
                // This may be a ECDSA certificate, hash the entire cert.
 | 
			
		||||
                obj.webCertificateHashs[i] = obj.webCertificateFullHashs[i];
 | 
			
		||||
            }
 | 
			
		||||
        } else if ((obj.parent.config.domains[i].dns != null) && (obj.certificates.dns[i] != null)) {
 | 
			
		||||
            // If this domain has a DNS and a matching DNS cert, use it. This case works for wildcard certs.
 | 
			
		||||
            obj.webCertificateFullHashs[i] = parent.certificateOperations.getCertHashBinary(obj.certificates.dns[i].cert);
 | 
			
		||||
            obj.webCertificateHashs[i] = parent.certificateOperations.getPublicKeyHashBinary(obj.certificates.dns[i].cert);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2403,6 +2407,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
 | 
			
		|||
                try { obj.meshAgentHandler.CreateMeshAgent(obj, obj.db, ws, req, obj.args, domain); } catch (e) { console.log(e); }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            // Memory Tracking
 | 
			
		||||
            if (typeof obj.args.memorytracking == 'number') {
 | 
			
		||||
                obj.app.get(url + 'memorytracking.csv', function (req, res) {
 | 
			
		||||
                    try { res.sendFile(obj.parent.getConfigFilePath('memorytracking.csv')); } catch (e) { res.sendStatus(404); }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Creates a login token using the user/pass that is passed in as URL arguments.
 | 
			
		||||
            // For example: https://localhost/createLoginToken.ashx?user=admin&pass=admin&a=3
 | 
			
		||||
            // It's not advised to use this to create login tokens since the URL is often logged and you got credentials in the URL.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue