mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-27 15:45:53 -05:00
Updated metadata and modified amt-lme to hook newListener for 'connect' because JS HECI is much faster than old implementation
This commit is contained in:
parent
e64162f67e
commit
5432ade256
@ -173,6 +173,12 @@ function createMeshCore(agent) {
|
|||||||
case 'connection':
|
case 'connection':
|
||||||
data.result = require('MeshAgent').ConnectedServer;
|
data.result = require('MeshAgent').ConnectedServer;
|
||||||
this._send(data);
|
this._send(data);
|
||||||
|
case 'descriptors':
|
||||||
|
require('ChainViewer').getSnapshot().then(function (f)
|
||||||
|
{
|
||||||
|
this.tag.payload.result = f;
|
||||||
|
this.tag.ipc._send(this.tag.payload);
|
||||||
|
}).parentPromise.tag = { ipc: this, payload: data };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -117,6 +117,7 @@ function lme_heci(options) {
|
|||||||
emitterUtils.createEvent('notify');
|
emitterUtils.createEvent('notify');
|
||||||
emitterUtils.createEvent('bind');
|
emitterUtils.createEvent('bind');
|
||||||
|
|
||||||
|
this.on('newListener', function (name, func) { if (name == 'connect' && this._LME._connected == true) { func.call(this);} });
|
||||||
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
|
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
|
||||||
|
|
||||||
var heci = require('heci');
|
var heci = require('heci');
|
||||||
@ -124,10 +125,14 @@ function lme_heci(options) {
|
|||||||
|
|
||||||
this._ObjectID = "lme";
|
this._ObjectID = "lme";
|
||||||
this._LME = heci.create();
|
this._LME = heci.create();
|
||||||
|
this._LME._connected = false;
|
||||||
|
this._LME.descriptorMetadata = "amt-lme";
|
||||||
this._LME._binded = {};
|
this._LME._binded = {};
|
||||||
this._LME.LMS = this;
|
this._LME.LMS = this;
|
||||||
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
|
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
|
||||||
this._LME.on('connect', function () {
|
this._LME.on('connect', function ()
|
||||||
|
{
|
||||||
|
this._connected = true;
|
||||||
this.on('data', function (chunk) {
|
this.on('data', function (chunk) {
|
||||||
// this = HECI
|
// this = HECI
|
||||||
var cmd = chunk.readUInt8(0);
|
var cmd = chunk.readUInt8(0);
|
||||||
@ -173,6 +178,7 @@ function lme_heci(options) {
|
|||||||
try {
|
try {
|
||||||
// Bind a new server socket if not already present
|
// Bind a new server socket if not already present
|
||||||
this[name][port] = require('net').createServer();
|
this[name][port] = require('net').createServer();
|
||||||
|
this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')';
|
||||||
this[name][port].HECI = this;
|
this[name][port].HECI = this;
|
||||||
if (lme_port_offset == 0) {
|
if (lme_port_offset == 0) {
|
||||||
this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
|
this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
|
||||||
|
@ -27,6 +27,7 @@ function amt_heci() {
|
|||||||
this._setupPTHI = function _setupPTHI()
|
this._setupPTHI = function _setupPTHI()
|
||||||
{
|
{
|
||||||
this._amt = heci.create();
|
this._amt = heci.create();
|
||||||
|
this._amt.descriptorMetadata = "amt-pthi";
|
||||||
this._amt.BiosVersionLen = 65;
|
this._amt.BiosVersionLen = 65;
|
||||||
this._amt.UnicodeStringLen = 20;
|
this._amt.UnicodeStringLen = 20;
|
||||||
|
|
||||||
@ -397,20 +398,25 @@ function amt_heci() {
|
|||||||
fn.apply(this, opt);
|
fn.apply(this, opt);
|
||||||
}, callback, optional);
|
}, callback, optional);
|
||||||
}
|
}
|
||||||
this.getProtocolVersion = function getProtocolVersion(callback) {
|
this.getProtocolVersion = function getProtocolVersion(callback)
|
||||||
|
{
|
||||||
var optional = [];
|
var optional = [];
|
||||||
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
||||||
|
|
||||||
heci.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt) {
|
if (!this._tmpSession) { this._tmpSession = heci.create(); this._tmpSession.parent = this;}
|
||||||
|
this._tmpSession.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt)
|
||||||
|
{
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
||||||
opt.unshift(result);
|
opt.unshift(result);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
opt.unshift(null);
|
opt.unshift(null);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this, callback, optional);
|
}, this, callback, optional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ function lme_heci(options) {
|
|||||||
emitterUtils.createEvent('notify');
|
emitterUtils.createEvent('notify');
|
||||||
emitterUtils.createEvent('bind');
|
emitterUtils.createEvent('bind');
|
||||||
|
|
||||||
|
this.on('newListener', function (name, func) { if (name == 'connect' && this._LME._connected == true) { func.call(this);} });
|
||||||
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
|
if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode
|
||||||
|
|
||||||
var heci = require('heci');
|
var heci = require('heci');
|
||||||
@ -124,10 +125,14 @@ function lme_heci(options) {
|
|||||||
|
|
||||||
this._ObjectID = "lme";
|
this._ObjectID = "lme";
|
||||||
this._LME = heci.create();
|
this._LME = heci.create();
|
||||||
|
this._LME._connected = false;
|
||||||
|
this._LME.descriptorMetadata = "amt-lme";
|
||||||
this._LME._binded = {};
|
this._LME._binded = {};
|
||||||
this._LME.LMS = this;
|
this._LME.LMS = this;
|
||||||
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
|
this._LME.on('error', function (e) { this.LMS.emit('error', e); });
|
||||||
this._LME.on('connect', function () {
|
this._LME.on('connect', function ()
|
||||||
|
{
|
||||||
|
this._connected = true;
|
||||||
this.on('data', function (chunk) {
|
this.on('data', function (chunk) {
|
||||||
// this = HECI
|
// this = HECI
|
||||||
var cmd = chunk.readUInt8(0);
|
var cmd = chunk.readUInt8(0);
|
||||||
@ -173,6 +178,7 @@ function lme_heci(options) {
|
|||||||
try {
|
try {
|
||||||
// Bind a new server socket if not already present
|
// Bind a new server socket if not already present
|
||||||
this[name][port] = require('net').createServer();
|
this[name][port] = require('net').createServer();
|
||||||
|
this[name][port].descriptorMetadata = 'amt-lme (port: ' + port + ')';
|
||||||
this[name][port].HECI = this;
|
this[name][port].HECI = this;
|
||||||
if (lme_port_offset == 0) {
|
if (lme_port_offset == 0) {
|
||||||
this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
|
this[name][port].listen({ port: port, host: '127.0.0.1' }); // Normal mode
|
||||||
|
@ -27,6 +27,7 @@ function amt_heci() {
|
|||||||
this._setupPTHI = function _setupPTHI()
|
this._setupPTHI = function _setupPTHI()
|
||||||
{
|
{
|
||||||
this._amt = heci.create();
|
this._amt = heci.create();
|
||||||
|
this._amt.descriptorMetadata = "amt-pthi";
|
||||||
this._amt.BiosVersionLen = 65;
|
this._amt.BiosVersionLen = 65;
|
||||||
this._amt.UnicodeStringLen = 20;
|
this._amt.UnicodeStringLen = 20;
|
||||||
|
|
||||||
@ -397,20 +398,25 @@ function amt_heci() {
|
|||||||
fn.apply(this, opt);
|
fn.apply(this, opt);
|
||||||
}, callback, optional);
|
}, callback, optional);
|
||||||
}
|
}
|
||||||
this.getProtocolVersion = function getProtocolVersion(callback) {
|
this.getProtocolVersion = function getProtocolVersion(callback)
|
||||||
|
{
|
||||||
var optional = [];
|
var optional = [];
|
||||||
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
||||||
|
|
||||||
heci.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt) {
|
if (!this._tmpSession) { this._tmpSession = heci.create(); this._tmpSession.parent = this;}
|
||||||
|
this._tmpSession.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt)
|
||||||
|
{
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
||||||
opt.unshift(result);
|
opt.unshift(result);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
opt.unshift(null);
|
opt.unshift(null);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this, callback, optional);
|
}, this, callback, optional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user