1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Many Intel AMT improvements.

This commit is contained in:
Ylian Saint-Hilaire 2020-10-09 15:44:09 -07:00
parent bc4e07b5fe
commit c0018bb467
12 changed files with 308 additions and 156 deletions

View file

@ -3507,15 +3507,20 @@ function createMeshCore(agent) {
mpskeepalive: 60000,
clientname: require('os').hostname(),
clientaddress: '127.0.0.1',
clientuuid: meshCoreObj.intelamt.uuid
clientuuid: meshCoreObj.intelamt.uuid,
conntype: 2 // 0 = CIRA, 1 = Relay, 2 = LMS. The correct value is 2 since we are performing an LMS relay, other values for testing.
};
var tobj = { debug: false }; //
apftunnel = require('apfclient')(tobj, apfarg);
try {
apftunnel.connect();
response += "..success";
} catch (e) {
response += JSON.stringify(e);
if ((apfarg.clientuuid == null) || (apfarg.clientuuid.length != 36)) {
response = "Unable to get Intel AMT UUID: " + apfarg.clientuuid;
} else {
var tobj = { debug: false };
apftunnel = require('apfclient')(tobj, apfarg);
try {
apftunnel.connect();
response += "...success";
} catch (e) {
response += JSON.stringify(e);
}
}
} else if (args['_'][0] == 'off') {
response = "Stopping APF tunnel";
@ -3640,18 +3645,10 @@ function createMeshCore(agent) {
{
switch(amt.lmsstate)
{
case 0:
intelamt.microlms = 'DISABLED'
break;
case 1:
intelamt.microlms = 'CONNECTING'
break;
case 2:
intelamt.microlms = 'CONNECTED'
break;
default:
intelamt.microlms = 'unknown'
break;
case 0: intelamt.microlms = 'DISABLED'; break;
case 1: intelamt.microlms = 'CONNECTING'; break;
case 2: intelamt.microlms = 'CONNECTED'; break;
default: intelamt.microlms = 'unknown'; break;
}
}
var p = false;

View file

@ -7,6 +7,8 @@
*/
function CreateAPFClient(parent, args) {
if ((args.clientuuid == null) || (args.clientuuid.length != 36)) return null; // Require a UUID if this exact length
var obj = {};
obj.parent = parent;
obj.args = args;
@ -57,7 +59,7 @@ function CreateAPFClient(parent, args) {
// Intel AMT forwarded port list for non-TLS mode
//var pfwd_ports = [16992, 623, 16994, 5900];
var pfwd_ports = [ 16992 ];
var pfwd_ports = [ 16992, 16993 ];
// protocol definitions
var APFProtocol = {
@ -81,7 +83,8 @@ function CreateAPFClient(parent, args) {
KEEPALIVE_REQUEST: 208,
KEEPALIVE_REPLY: 209,
KEEPALIVE_OPTIONS_REQUEST: 210,
KEEPALIVE_OPTIONS_REPLY: 211
KEEPALIVE_OPTIONS_REPLY: 211,
MESH_CONNECTION_TYPE: 250 // This is a Mesh specific command that instructs the server of the connection type: 1 = Relay, 2 = LMS.
}
var APFDisconnectCode = {
@ -160,13 +163,18 @@ function CreateAPFClient(parent, args) {
});
obj.state = CIRASTATE.INITIAL;
if (typeof obj.args.conntype == 'number') { SendConnectionType(obj.forwardClient.ws, obj.args.conntype); }
SendProtocolVersion(obj.forwardClient.ws, obj.args.clientuuid);
SendServiceRequest(obj.forwardClient.ws, 'auth@amt.intel.com');
}
function SendConnectionType(socket, type) {
socket.write(String.fromCharCode(APFProtocol.MESH_CONNECTION_TYPE) + IntToStr(type));
Debug("APF: Send connection type " + type);
}
function SendProtocolVersion(socket, uuid) {
var buuid = strToGuid(uuid);
var data = String.fromCharCode(APFProtocol.PROTOCOLVERSION) + '' + IntToStr(1) + IntToStr(0) + IntToStr(0) + hex2rstr(buuid) + binzerostring(64);
var data = String.fromCharCode(APFProtocol.PROTOCOLVERSION) + IntToStr(1) + IntToStr(0) + IntToStr(0) + hex2rstr(strToGuid(uuid)) + binzerostring(64);
socket.write(data);
Debug("APF: Send protocol version 1 0 " + uuid);
obj.cirastate = CIRASTATE.PROTOCOL_VERSION_SENT;