mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Partial work for host-based ACM AMT activation.
This commit is contained in:
parent
cfb9af8609
commit
423daaf19d
11 changed files with 143 additions and 15 deletions
|
@ -1174,6 +1174,14 @@ function configureJsonControl(data) {
|
|||
amtMei.on('error', function (e) { settings.apftunnel.sendMeiDeactivationState(1); });
|
||||
amtMei.unprovision(1, function (status) { settings.apftunnel.sendMeiDeactivationState(status); }); // 0 = Success
|
||||
break;
|
||||
case 'startTlsHostConfig': // Request start of host based TLS ACM activation
|
||||
var amtMeiModule, amtMei;
|
||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { settings.apftunnel.sendStartTlsHostConfigResponse({ state: -103 }); break; }
|
||||
amtMei.on('error', function (e) { settings.apftunnel.sendStartTlsHostConfigResponse({ state: -104 }); });
|
||||
amtMei.startConfigurationHBased(Buffer.from(data.hash, 'hex'), data.hostVpn, data.dnsSuffixList, function (response) {
|
||||
settings.apftunnel.sendStartTlsHostConfigResponse(response);
|
||||
});
|
||||
break;
|
||||
case 'close': // Close the CIRA-LMS connection
|
||||
exit(0);
|
||||
break;
|
||||
|
|
|
@ -1197,6 +1197,11 @@ function handleServerCommand(data) {
|
|||
amtMei.unprovision(1, function (status) { if (apftunnel) apftunnel.sendMeiDeactivationState(status); }); // 0 = Success
|
||||
}
|
||||
if (data.action == 'close') { try { apftunnel.disconnect(); } catch (e) { } apftunnel = null; } // Close the CIRA-LMS connection
|
||||
if (data.action == 'startTlsHostConfig') { // Request start of host based TLS ACM activation
|
||||
amt.startConfigurationHBased(Buffer.from(data.hash, 'hex'), data.hostVpn, data.dnsSuffixList, function (response) {
|
||||
apftunnel.sendStartTlsHostConfigResponse(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
apftunnel.onChannelClosed = function () { addAmtEvent('LMS tunnel closed.'); apftunnel = null; }
|
||||
try { apftunnel.connect(); } catch (ex) { }
|
||||
|
|
|
@ -183,6 +183,7 @@ function CreateAPFClient(parent, args) {
|
|||
|
||||
obj.updateMeiState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: state }); }
|
||||
obj.sendMeiDeactivationState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'deactivate', value: state }); }
|
||||
obj.sendStartTlsHostConfigResponse = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'startTlsHostConfig', value: state }); }
|
||||
|
||||
function SendJsonControl(socket, o) {
|
||||
var data = JSON.stringify(o)
|
||||
|
|
|
@ -419,8 +419,8 @@ function amt_heci() {
|
|||
|
||||
}, this, callback, optional);
|
||||
}
|
||||
this.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, callback) {
|
||||
if ((certHash == null) || ((certHash.length != 32) && (certHash.length != 48))) { throw "Bad certHash"; }
|
||||
this.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func) {
|
||||
if ((certHash == null) || ((certHash.length != 32) && (certHash.length != 48))) { func({ status: -101 }); }
|
||||
|
||||
var optional = [];
|
||||
for (var i = 4; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
|
@ -447,8 +447,23 @@ function amt_heci() {
|
|||
opt.unshift({ status: header.Status });
|
||||
}
|
||||
fn.apply(this, opt);
|
||||
}, callback, optional);
|
||||
}, func, optional);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = amt_heci;
|
||||
module.exports = amt_heci;
|
||||
|
||||
|
||||
/*
|
||||
AMT_STATUS_SUCCESS = 0,
|
||||
AMT_STATUS_INTERNAL_ERROR = 1,
|
||||
AMT_STATUS_INVALID_AMT_MODE = 3,
|
||||
AMT_STATUS_INVALID_MESSAGE_LENGTH = 4,
|
||||
AMT_STATUS_MAX_LIMIT_REACHED = 23,
|
||||
AMT_STATUS_INVALID_PARAMETER = 36,
|
||||
AMT_STATUS_RNG_GENERATION_IN_PROGRESS = 47,
|
||||
AMT_STATUS_RNG_NOT_READY = 48,
|
||||
AMT_STATUS_CERTIFICATE_NOT_READY = 49,
|
||||
AMT_STATUS_INVALID_HANDLE = 2053
|
||||
AMT_STATUS_NOT_FOUND = 2068,
|
||||
*/
|
|
@ -183,6 +183,7 @@ function CreateAPFClient(parent, args) {
|
|||
|
||||
obj.updateMeiState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'meiState', value: state }); }
|
||||
obj.sendMeiDeactivationState = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'deactivate', value: state }); }
|
||||
obj.sendStartTlsHostConfigResponse = function (state) { SendJsonControl(obj.forwardClient.ws, { action: 'startTlsHostConfig', value: state }); }
|
||||
|
||||
function SendJsonControl(socket, o) {
|
||||
var data = JSON.stringify(o)
|
||||
|
|
|
@ -157,6 +157,12 @@ function AmtManager(agent, db, isdebug) {
|
|||
}
|
||||
}
|
||||
|
||||
// Start host based ACM activation with TLS
|
||||
obj.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func) {
|
||||
if ((amtMei == null) || (amtMeiState < 2)) { if (func != null) { func({ status: -100 }); } return; }
|
||||
amtMei.startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = AmtManager;
|
||||
|
|
|
@ -419,8 +419,8 @@ function amt_heci() {
|
|||
|
||||
}, this, callback, optional);
|
||||
}
|
||||
this.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, callback) {
|
||||
if ((certHash == null) || ((certHash.length != 32) && (certHash.length != 48))) { throw "Bad certHash"; }
|
||||
this.startConfigurationHBased = function startConfigurationHBased(certHash, hostVpn, dnsSuffixList, func) {
|
||||
if ((certHash == null) || ((certHash.length != 32) && (certHash.length != 48))) { func({ status: -101 }); }
|
||||
|
||||
var optional = [];
|
||||
for (var i = 4; i < arguments.length; ++i) { optional.push(arguments[i]); }
|
||||
|
@ -447,8 +447,23 @@ function amt_heci() {
|
|||
opt.unshift({ status: header.Status });
|
||||
}
|
||||
fn.apply(this, opt);
|
||||
}, callback, optional);
|
||||
}, func, optional);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = amt_heci;
|
||||
module.exports = amt_heci;
|
||||
|
||||
|
||||
/*
|
||||
AMT_STATUS_SUCCESS = 0,
|
||||
AMT_STATUS_INTERNAL_ERROR = 1,
|
||||
AMT_STATUS_INVALID_AMT_MODE = 3,
|
||||
AMT_STATUS_INVALID_MESSAGE_LENGTH = 4,
|
||||
AMT_STATUS_MAX_LIMIT_REACHED = 23,
|
||||
AMT_STATUS_INVALID_PARAMETER = 36,
|
||||
AMT_STATUS_RNG_GENERATION_IN_PROGRESS = 47,
|
||||
AMT_STATUS_RNG_NOT_READY = 48,
|
||||
AMT_STATUS_CERTIFICATE_NOT_READY = 49,
|
||||
AMT_STATUS_INVALID_HANDLE = 2053
|
||||
AMT_STATUS_NOT_FOUND = 2068,
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue