mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-23 22:13:14 +03:00
Updated Windows MeshAgents + UTF8 string encoding fixes.
This commit is contained in:
parent
ed7f1a549a
commit
bb4bc55c48
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
agents/meshcore.min.js
vendored
9
agents/meshcore.min.js
vendored
@ -709,16 +709,14 @@ function createMeshCore(agent)
|
|||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
case 'serviceRestart': {
|
case 'serviceRestart': {
|
||||||
// Start a service
|
// Restart a service
|
||||||
try {
|
try {
|
||||||
var service = require('service-manager').manager.getService(data.serviceName);
|
var service = require('service-manager').manager.getService(data.serviceName);
|
||||||
if (service != null) { service.stop(); service.start(); }
|
if (service != null) { service.restart(); }
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
case 'openUrl': {
|
case 'openUrl': {
|
||||||
// Open a local web browser and return success/fail
|
// Open a local web browser and return success/fail
|
||||||
MeshServerLog('Opening: ' + data.url, data);
|
MeshServerLog('Opening: ' + data.url, data);
|
||||||
@ -1826,8 +1824,9 @@ function createMeshCore(agent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'sysinfo': { // Return system information
|
case 'sysinfo': { // Return system information
|
||||||
var results = { hardware: require('identifiers').get(), pendingReboot: require('win-info').pendingReboot() }; // Hardware && pending reboot
|
var results = { hardware: require('identifiers').get() }; // Hardware && pending reboot
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
|
results.pendingReboot = require('win-info').pendingReboot();
|
||||||
var defragResult = function (r) {
|
var defragResult = function (r) {
|
||||||
if (typeof r == 'object') { results[this.callname] = r; }
|
if (typeof r == 'object') { results[this.callname] = r; }
|
||||||
if (this.callname == 'defrag') {
|
if (this.callname == 'defrag') {
|
||||||
|
65
meshagent.js
65
meshagent.js
@ -39,7 +39,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
//obj.agentInfo = null;
|
//obj.agentInfo = null;
|
||||||
|
|
||||||
// Send a message to the mesh agent
|
// Send a message to the mesh agent
|
||||||
obj.send = function (data, func) { try { if (typeof data == 'string') { ws.send(Buffer.from(data, 'binary'), func); } else { ws.send(data, func); } } catch (e) { } };
|
obj.send = function (data, func) { try { if (typeof data == 'string') { ws.send(Buffer.from(data), func); } else { ws.send(data, func); } } catch (e) { } };
|
||||||
|
obj.sendBinary = function (data, func) { try { if (typeof data == 'string') { ws.send(Buffer.from(data, 'binary'), func); } else { ws.send(data, func); } } catch (e) { } };
|
||||||
|
|
||||||
// Disconnect this agent
|
// Disconnect this agent
|
||||||
obj.close = function (arg) {
|
obj.close = function (arg) {
|
||||||
@ -125,7 +126,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
|
|
||||||
// If we are using a custom core, don't try to update it.
|
// If we are using a custom core, don't try to update it.
|
||||||
if (obj.agentCoreCheck == 1000) {
|
if (obj.agentCoreCheck == 1000) {
|
||||||
obj.send(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
obj.sendBinary(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
||||||
agentCoreIsStable();
|
agentCoreIsStable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// If the agent indicates this is a custom core, we are done.
|
// If the agent indicates this is a custom core, we are done.
|
||||||
if ((agentMeshCoreHash != null) && (agentMeshCoreHash == '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')) {
|
if ((agentMeshCoreHash != null) && (agentMeshCoreHash == '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0')) {
|
||||||
obj.agentCoreCheck = 0;
|
obj.agentCoreCheck = 0;
|
||||||
obj.send(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
obj.sendBinary(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
||||||
agentCoreIsStable();
|
agentCoreIsStable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -163,12 +164,12 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
if ((obj.agentCoreCheck < 5) || (obj.agentCoreCheck == 1001)) {
|
if ((obj.agentCoreCheck < 5) || (obj.agentCoreCheck == 1001)) {
|
||||||
if (meshcorehash == null) {
|
if (meshcorehash == null) {
|
||||||
// Clear the core
|
// Clear the core
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0)); // MeshCommand_CoreModule, ask mesh agent to clear the core
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0)); // MeshCommand_CoreModule, ask mesh agent to clear the core
|
||||||
parent.agentStats.clearingCoreCount++;
|
parent.agentStats.clearingCoreCount++;
|
||||||
parent.parent.debug(1, 'Clearing core');
|
parent.parent.debug(1, 'Clearing core');
|
||||||
} else {
|
} else {
|
||||||
// Update new core
|
// Update new core
|
||||||
//obj.send(common.ShortToStr(10) + common.ShortToStr(0) + meshcorehash + parent.parent.defaultMeshCores[corename]); // MeshCommand_CoreModule, start core update
|
//obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0) + meshcorehash + parent.parent.defaultMeshCores[corename]); // MeshCommand_CoreModule, start core update
|
||||||
//parent.parent.debug(1, 'Updating code ' + corename);
|
//parent.parent.debug(1, 'Updating code ' + corename);
|
||||||
|
|
||||||
// Update new core with task limiting so not to flood the server. This is a high priority task.
|
// Update new core with task limiting so not to flood the server. This is a high priority task.
|
||||||
@ -177,7 +178,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
if (obj.authenticated == 2) {
|
if (obj.authenticated == 2) {
|
||||||
// Send the updated code.
|
// Send the updated code.
|
||||||
delete obj.agentCoreUpdatePending;
|
delete obj.agentCoreUpdatePending;
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0) + argument.hash + argument.core, function () { parent.parent.taskLimiter.completed(taskid); }); // MeshCommand_CoreModule, start core update
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0) + argument.hash + argument.core, function () { parent.parent.taskLimiter.completed(taskid); }); // MeshCommand_CoreModule, start core update
|
||||||
parent.agentStats.updatingCoreCount++;
|
parent.agentStats.updatingCoreCount++;
|
||||||
parent.parent.debug(1, 'Updating core ' + argument.name);
|
parent.parent.debug(1, 'Updating core ' + argument.name);
|
||||||
agentCoreIsStable();
|
agentCoreIsStable();
|
||||||
@ -191,7 +192,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obj.agentCoreCheck = 0;
|
obj.agentCoreCheck = 0;
|
||||||
obj.send(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
obj.sendBinary(common.ShortToStr(16) + common.ShortToStr(0)); // MeshCommand_CoreOk. Indicates to the agent that the core is ok. Start it if it's not already started.
|
||||||
agentCoreIsStable(); // No updates needed, agent is ready to go.
|
agentCoreIsStable(); // No updates needed, agent is ready to go.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,13 +205,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
if (obj.agentCoreCheck < 5) { // This check is in place to avoid a looping core update.
|
if (obj.agentCoreCheck < 5) { // This check is in place to avoid a looping core update.
|
||||||
if (parent.parent.defaultMeshCoreHash == null) {
|
if (parent.parent.defaultMeshCoreHash == null) {
|
||||||
// Update no core
|
// Update no core
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0)); // Command 10, ask mesh agent to clear the core
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0)); // Command 10, ask mesh agent to clear the core
|
||||||
} else {
|
} else {
|
||||||
// Update new core
|
// Update new core
|
||||||
if (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].amt == true) {
|
if (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].amt == true) {
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0) + parent.parent.defaultMeshCoreHash + parent.parent.defaultMeshCore); // Command 10, ask mesh agent to set the core (with MEI support)
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0) + parent.parent.defaultMeshCoreHash + parent.parent.defaultMeshCore); // Command 10, ask mesh agent to set the core (with MEI support)
|
||||||
} else {
|
} else {
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0) + parent.parent.defaultMeshCoreNoMeiHash + parent.parent.defaultMeshCoreNoMei); // Command 10, ask mesh agent to set the core (No MEI)
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0) + parent.parent.defaultMeshCoreNoMeiHash + parent.parent.defaultMeshCoreNoMei); // Command 10, ask mesh agent to set the core (No MEI)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.agentCoreCheck++;
|
obj.agentCoreCheck++;
|
||||||
@ -238,11 +239,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
|
|
||||||
// MeshCommand_CoreModule, ask mesh agent to clear the core.
|
// MeshCommand_CoreModule, ask mesh agent to clear the core.
|
||||||
// The new core will only be sent after the agent updates.
|
// The new core will only be sent after the agent updates.
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0));
|
||||||
|
|
||||||
// We got the agent file open on the server side, tell the agent we are sending an update starting with the SHA384 hash of the result
|
// We got the agent file open on the server side, tell the agent we are sending an update starting with the SHA384 hash of the result
|
||||||
//console.log("Agent update file open.");
|
//console.log("Agent update file open.");
|
||||||
obj.send(common.ShortToStr(13) + common.ShortToStr(0)); // Command 13, start mesh agent download
|
obj.sendBinary(common.ShortToStr(13) + common.ShortToStr(0)); // Command 13, start mesh agent download
|
||||||
|
|
||||||
// Send the first mesh agent update data block
|
// Send the first mesh agent update data block
|
||||||
obj.agentUpdate.buf[0] = 0;
|
obj.agentUpdate.buf[0] = 0;
|
||||||
@ -260,7 +261,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Send the first block to the agent
|
// Send the first block to the agent
|
||||||
obj.agentUpdate.ptr += bytesRead;
|
obj.agentUpdate.ptr += bytesRead;
|
||||||
//console.log("Agent update send first block: " + bytesRead);
|
//console.log("Agent update send first block: " + bytesRead);
|
||||||
obj.send(obj.agentUpdate.buf); // Command 14, mesh agent first data block
|
obj.sendBinary(obj.agentUpdate.buf); // Command 14, mesh agent first data block
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -270,10 +271,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
|
|
||||||
// MeshCommand_CoreModule, ask mesh agent to clear the core.
|
// MeshCommand_CoreModule, ask mesh agent to clear the core.
|
||||||
// The new core will only be sent after the agent updates.
|
// The new core will only be sent after the agent updates.
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0));
|
||||||
|
|
||||||
// We got the agent file open on the server side, tell the agent we are sending an update starting with the SHA384 hash of the result
|
// We got the agent file open on the server side, tell the agent we are sending an update starting with the SHA384 hash of the result
|
||||||
obj.send(common.ShortToStr(13) + common.ShortToStr(0)); // Command 13, start mesh agent download
|
obj.sendBinary(common.ShortToStr(13) + common.ShortToStr(0)); // Command 13, start mesh agent download
|
||||||
|
|
||||||
// Send the first mesh agent update data block
|
// Send the first mesh agent update data block
|
||||||
obj.agentUpdate.buf[0] = 0;
|
obj.agentUpdate.buf[0] = 0;
|
||||||
@ -286,7 +287,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Send the first block
|
// Send the first block
|
||||||
obj.agentExeInfo.data.copy(obj.agentUpdate.buf, 4, obj.agentUpdate.ptr, obj.agentUpdate.ptr + len);
|
obj.agentExeInfo.data.copy(obj.agentUpdate.buf, 4, obj.agentUpdate.ptr, obj.agentUpdate.ptr + len);
|
||||||
obj.agentUpdate.ptr += len;
|
obj.agentUpdate.ptr += len;
|
||||||
obj.send(obj.agentUpdate.buf); // Command 14, mesh agent first data block
|
obj.sendBinary(obj.agentUpdate.buf); // Command 14, mesh agent first data block
|
||||||
} else {
|
} else {
|
||||||
// Error
|
// Error
|
||||||
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
|
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
|
||||||
@ -299,7 +300,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
} else {
|
} else {
|
||||||
// Check the mesh core, if the agent is capable of running one
|
// Check the mesh core, if the agent is capable of running one
|
||||||
if (((obj.agentInfo.capabilities & 16) != 0) && (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core != null)) {
|
if (((obj.agentInfo.capabilities & 16) != 0) && (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core != null)) {
|
||||||
obj.send(common.ShortToStr(11) + common.ShortToStr(0)); // Command 11, ask for mesh core hash.
|
obj.sendBinary(common.ShortToStr(11) + common.ShortToStr(0)); // Command 11, ask for mesh core hash.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,10 +323,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Send the next block to the agent
|
// Send the next block to the agent
|
||||||
obj.agentUpdate.ptr += bytesRead;
|
obj.agentUpdate.ptr += bytesRead;
|
||||||
//console.log("Agent update send next block", obj.agentUpdate.ptr, bytesRead);
|
//console.log("Agent update send next block", obj.agentUpdate.ptr, bytesRead);
|
||||||
if (bytesRead == agentUpdateBlockSize) { obj.send(obj.agentUpdate.buf); } else { obj.send(obj.agentUpdate.buf.slice(0, bytesRead + 4)); } // Command 14, mesh agent next data block
|
if (bytesRead == agentUpdateBlockSize) { obj.sendBinary(obj.agentUpdate.buf); } else { obj.sendBinary(obj.agentUpdate.buf.slice(0, bytesRead + 4)); } // Command 14, mesh agent next data block
|
||||||
if (bytesRead < agentUpdateBlockSize) {
|
if (bytesRead < agentUpdateBlockSize) {
|
||||||
//console.log("Agent update sent from disk.");
|
//console.log("Agent update sent from disk.");
|
||||||
obj.send(common.ShortToStr(13) + common.ShortToStr(0) + obj.agentExeInfo.hash); // Command 13, end mesh agent download, send agent SHA384 hash
|
obj.sendBinary(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) { }
|
try { parent.fs.close(obj.agentUpdate.fd); } catch (ex) { }
|
||||||
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
|
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
|
||||||
delete obj.agentUpdate.buf;
|
delete obj.agentUpdate.buf;
|
||||||
@ -338,13 +339,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
const len = Math.min(agentUpdateBlockSize, obj.agentExeInfo.data.length - obj.agentUpdate.ptr);
|
const len = Math.min(agentUpdateBlockSize, obj.agentExeInfo.data.length - obj.agentUpdate.ptr);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
obj.agentExeInfo.data.copy(obj.agentUpdate.buf, 4, obj.agentUpdate.ptr, obj.agentUpdate.ptr + len);
|
obj.agentExeInfo.data.copy(obj.agentUpdate.buf, 4, obj.agentUpdate.ptr, obj.agentUpdate.ptr + len);
|
||||||
if (len == agentUpdateBlockSize) { obj.send(obj.agentUpdate.buf); } else { obj.send(obj.agentUpdate.buf.slice(0, len + 4)); } // Command 14, mesh agent next data block
|
if (len == agentUpdateBlockSize) { obj.sendBinary(obj.agentUpdate.buf); } else { obj.sendBinary(obj.agentUpdate.buf.slice(0, len + 4)); } // Command 14, mesh agent next data block
|
||||||
obj.agentUpdate.ptr += len;
|
obj.agentUpdate.ptr += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.agentUpdate.ptr == obj.agentExeInfo.data.length) {
|
if (obj.agentUpdate.ptr == obj.agentExeInfo.data.length) {
|
||||||
//console.log("Agent update sent from RAM.");
|
//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
|
obj.sendBinary(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
|
parent.parent.taskLimiter.completed(obj.agentUpdate.taskid); // Indicate this task complete
|
||||||
delete obj.agentUpdate.buf;
|
delete obj.agentUpdate.buf;
|
||||||
delete obj.agentUpdate;
|
delete obj.agentUpdate;
|
||||||
@ -367,7 +368,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
|
|
||||||
if (args.ignoreagenthashcheck === true) {
|
if (args.ignoreagenthashcheck === true) {
|
||||||
// Send the agent web hash back to the agent
|
// Send the agent web hash back to the agent
|
||||||
obj.send(common.ShortToStr(1) + msg.substring(2, 50) + obj.nonce); // Command 1, hash + nonce. Use the web hash given by the agent.
|
obj.sendBinary(common.ShortToStr(1) + msg.substring(2, 50) + obj.nonce); // Command 1, hash + nonce. Use the web hash given by the agent.
|
||||||
} else {
|
} else {
|
||||||
// Check that the server hash matches our own web certificate hash (SHA384)
|
// Check that the server hash matches our own web certificate hash (SHA384)
|
||||||
if ((getWebCertHash(domain) != msg.substring(2, 50)) && (getWebCertFullHash(domain) != msg.substring(2, 50))) {
|
if ((getWebCertHash(domain) != msg.substring(2, 50)) && (getWebCertFullHash(domain) != msg.substring(2, 50))) {
|
||||||
@ -388,13 +389,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Perform the hash signature using older swarm server certificate
|
// Perform the hash signature using older swarm server certificate
|
||||||
parent.parent.certificateOperations.acceleratorPerformSignature(1, msg.substring(2) + obj.nonce, obj, function (obj2, signature) {
|
parent.parent.certificateOperations.acceleratorPerformSignature(1, msg.substring(2) + obj.nonce, obj, function (obj2, signature) {
|
||||||
// Send back our certificate + signature
|
// Send back our certificate + signature
|
||||||
obj2.send(common.ShortToStr(2) + common.ShortToStr(parent.swarmCertificateAsn1.length) + parent.swarmCertificateAsn1 + signature); // Command 2, certificate + signature
|
obj2.sendBinary(common.ShortToStr(2) + common.ShortToStr(parent.swarmCertificateAsn1.length) + parent.swarmCertificateAsn1 + signature); // Command 2, certificate + signature
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Perform the hash signature using the server agent certificate
|
// Perform the hash signature using the server agent certificate
|
||||||
parent.parent.certificateOperations.acceleratorPerformSignature(0, msg.substring(2) + obj.nonce, obj, function (obj2, signature) {
|
parent.parent.certificateOperations.acceleratorPerformSignature(0, msg.substring(2) + obj.nonce, obj, function (obj2, signature) {
|
||||||
// Send back our certificate + signature
|
// Send back our certificate + signature
|
||||||
obj2.send(common.ShortToStr(2) + common.ShortToStr(parent.agentCertificateAsn1.length) + parent.agentCertificateAsn1 + signature); // Command 2, certificate + signature
|
obj2.sendBinary(common.ShortToStr(2) + common.ShortToStr(parent.agentCertificateAsn1.length) + parent.agentCertificateAsn1 + signature); // Command 2, certificate + signature
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,7 +486,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Start authenticate the mesh agent by sending a auth nonce & server TLS cert hash.
|
// Start authenticate the mesh agent by sending a auth nonce & server TLS cert hash.
|
||||||
// Send 384 bits SHA384 hash of TLS cert public key + 384 bits nonce
|
// Send 384 bits SHA384 hash of TLS cert public key + 384 bits nonce
|
||||||
if (args.ignoreagenthashcheck !== true) {
|
if (args.ignoreagenthashcheck !== true) {
|
||||||
obj.send(common.ShortToStr(1) + getWebCertHash(domain) + obj.nonce); // Command 1, hash + nonce
|
obj.sendBinary(common.ShortToStr(1) + getWebCertHash(domain) + obj.nonce); // Command 1, hash + nonce
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the mesh for this device, in some cases, we may auto-create the mesh.
|
// Return the mesh for this device, in some cases, we may auto-create the mesh.
|
||||||
@ -556,10 +557,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
// Inform mesh agent that it's authenticated.
|
// Inform mesh agent that it's authenticated.
|
||||||
delete obj.pendingCompleteAgentConnection;
|
delete obj.pendingCompleteAgentConnection;
|
||||||
obj.authenticated = 2;
|
obj.authenticated = 2;
|
||||||
obj.send(common.ShortToStr(4));
|
obj.sendBinary(common.ShortToStr(4));
|
||||||
|
|
||||||
// Ask for mesh core hash.
|
// Ask for mesh core hash.
|
||||||
obj.send(common.ShortToStr(11) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(11) + common.ShortToStr(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,11 +785,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command 4, inform mesh agent that it's authenticated.
|
// Command 4, inform mesh agent that it's authenticated.
|
||||||
obj.send(common.ShortToStr(4));
|
obj.sendBinary(common.ShortToStr(4));
|
||||||
|
|
||||||
if (disconnectCount > 4) {
|
if (disconnectCount > 4) {
|
||||||
// Too many disconnections, this agent has issues. Just clear the core.
|
// Too many disconnections, this agent has issues. Just clear the core.
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0));
|
||||||
//console.log('Agent in trouble: NodeId=' + obj.nodeid + ', IP=' + obj.remoteaddrport + ', Agent=' + obj.agentInfo.agentId + '.');
|
//console.log('Agent in trouble: NodeId=' + obj.nodeid + ', IP=' + obj.remoteaddrport + ', Agent=' + obj.agentInfo.agentId + '.');
|
||||||
// TODO: Log or do something to recover?
|
// TODO: Log or do something to recover?
|
||||||
return;
|
return;
|
||||||
@ -804,16 +805,16 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core;
|
corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core;
|
||||||
} else {
|
} else {
|
||||||
// MeshCommand_CoreModule, ask mesh agent to clear the core
|
// MeshCommand_CoreModule, ask mesh agent to clear the core
|
||||||
obj.send(common.ShortToStr(10) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(10) + common.ShortToStr(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((obj.agentExeInfo != null) && (obj.agentExeInfo.update == true)) {
|
if ((obj.agentExeInfo != null) && (obj.agentExeInfo.update == true)) {
|
||||||
// Ask the agent for it's executable binary hash
|
// Ask the agent for it's executable binary hash
|
||||||
obj.send(common.ShortToStr(12) + common.ShortToStr(0));
|
obj.sendBinary(common.ShortToStr(12) + common.ShortToStr(0));
|
||||||
} else {
|
} else {
|
||||||
// Check the mesh core, if the agent is capable of running one
|
// Check the mesh core, if the agent is capable of running one
|
||||||
if (((obj.agentInfo.capabilities & 16) != 0) && (corename != null)) {
|
if (((obj.agentInfo.capabilities & 16) != 0) && (corename != null)) {
|
||||||
obj.send(common.ShortToStr(11) + common.ShortToStr(0)); // Command 11, ask for mesh core hash.
|
obj.sendBinary(common.ShortToStr(11) + common.ShortToStr(0)); // Command 11, ask for mesh core hash.
|
||||||
} else {
|
} else {
|
||||||
agentCoreIsStable(); // No updates needed, agent is ready to go.
|
agentCoreIsStable(); // No updates needed, agent is ready to go.
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.3.9-n",
|
"version": "0.3.9-o",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
Loading…
Reference in New Issue
Block a user