mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added user events support in MicroLMS within MeshCmd.
This commit is contained in:
parent
007f150be0
commit
c210b926bc
12 changed files with 133 additions and 100 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -37,7 +37,6 @@ function createMeshCore(agent) {
|
||||||
var networkMonitor = null;
|
var networkMonitor = null;
|
||||||
var amtscanner = null;
|
var amtscanner = null;
|
||||||
var nextTunnelIndex = 1;
|
var nextTunnelIndex = 1;
|
||||||
var lastException = null;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var AMTScanner = require("AMTScanner");
|
var AMTScanner = require("AMTScanner");
|
||||||
|
@ -79,14 +78,14 @@ function createMeshCore(agent) {
|
||||||
amtMei = new amtMeiLib();
|
amtMei = new amtMeiLib();
|
||||||
amtMei.on('error', function (e) { amtMeiLib = null; amtMei = null; sendPeriodicServerUpdate(); });
|
amtMei.on('error', function (e) { amtMeiLib = null; amtMei = null; sendPeriodicServerUpdate(); });
|
||||||
amtMei.on('connect', function () { amtMeiConnected = 2; getAmtInfo(); });
|
amtMei.on('connect', function () { amtMeiConnected = 2; getAmtInfo(); });
|
||||||
} catch (e) { lastException = e; amtMeiLib = null; amtMei = null; amtMeiConnected = -1; }
|
} catch (e) { amtMeiLib = null; amtMei = null; amtMeiConnected = -1; }
|
||||||
|
|
||||||
// Try to load up the WIFI scanner
|
// Try to load up the WIFI scanner
|
||||||
try {
|
try {
|
||||||
var wifiScannerLib = require('wifi-scanner');
|
var wifiScannerLib = require('wifi-scanner');
|
||||||
wifiScanner = new wifiScannerLib();
|
wifiScanner = new wifiScannerLib();
|
||||||
wifiScanner.on('accessPoint', function (data) { sendConsoleText(JSON.stringify(data)); });
|
wifiScanner.on('accessPoint', function (data) { sendConsoleText(JSON.stringify(data)); });
|
||||||
} catch (e) { lastException = e; wifiScannerLib = null; wifiScanner = null; }
|
} catch (e) { wifiScannerLib = null; wifiScanner = null; }
|
||||||
|
|
||||||
// If we are running in Duktape, agent will be null
|
// If we are running in Duktape, agent will be null
|
||||||
if (agent == null) {
|
if (agent == null) {
|
||||||
|
@ -801,13 +800,12 @@ function createMeshCore(agent) {
|
||||||
}
|
}
|
||||||
case 'info': { // Return information about the agent and agent core module
|
case 'info': { // Return information about the agent and agent core module
|
||||||
response = 'Current Core: ' + obj.meshCoreInfo + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform Info: ' + process.platform + '.\r\nCapabilities: ' + obj.meshCoreCapabilities + '.\r\nServer URL: ' + mesh.ServerUrl + '.';
|
response = 'Current Core: ' + obj.meshCoreInfo + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform Info: ' + process.platform + '.\r\nCapabilities: ' + obj.meshCoreCapabilities + '.\r\nServer URL: ' + mesh.ServerUrl + '.';
|
||||||
if (amtLmsState >= 0) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected', 'Exception'][amtLmsState] + '.'; }
|
if (amtLmsState >= 0) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amtLmsState] + '.'; }
|
||||||
response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
|
response += '\r\nModules: ' + JSON.stringify(addedModules) + '';
|
||||||
response += '\r\nServerConnected: ' + mesh.isControlChannelConnected + '';
|
response += '\r\nServerConnected: ' + mesh.isControlChannelConnected + '';
|
||||||
var oldNodeId = db.Get('OldNodeId');
|
var oldNodeId = db.Get('OldNodeId');
|
||||||
if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
|
if (oldNodeId != null) { response += '\r\nOldNodeID: ' + oldNodeId + '.'; }
|
||||||
response += '\r\ServerState: ' + meshServerConnectionState + '.';
|
response += '\r\ServerState: ' + meshServerConnectionState + '.';
|
||||||
if (lastException != null) { response += '\r\LastException: ' + JSON.stringify(lastException) + '.'; }
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'selfinfo': { // Return self information block
|
case 'selfinfo': { // Return self information block
|
||||||
|
@ -1197,7 +1195,7 @@ function createMeshCore(agent) {
|
||||||
if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
|
if (str != null) { sendConsoleText('Intel AMT LMS: ' + str); }
|
||||||
handleAmtNotification(data);
|
handleAmtNotification(data);
|
||||||
});
|
});
|
||||||
} catch (e) { lastException = e; amtLmsState = 3; amtLms = null; }
|
} catch (e) { amtLmsState = -1; amtLms = null; }
|
||||||
|
|
||||||
// Check if the control channel is connected
|
// Check if the control channel is connected
|
||||||
if (mesh.isControlChannelConnected) {
|
if (mesh.isControlChannelConnected) {
|
||||||
|
|
|
@ -87,9 +87,9 @@ DownloadAgent() {
|
||||||
UpdateMshFile
|
UpdateMshFile
|
||||||
if [ $starttype -eq 1 ]
|
if [ $starttype -eq 1 ]
|
||||||
then
|
then
|
||||||
echo -e "[Unit]\nDescription=MeshCentral Agent\n[Service]\nExecStart=/usr/local/mesh/meshagent\nStandardOutput=null\n[Install]\nWantedBy=multi-user.target\nAlias=meshcentral.service\n" > /lib/systemd/system/meshcentral.service
|
echo -e "[Unit]\nDescription=MeshCentral Agent\n[Service]\nExecStart=/usr/local/mesh/meshagent\nStandardOutput=null\n[Install]\nWantedBy=multi-user.target\nAlias=meshagent.service\n" > /lib/systemd/system/meshagent.service
|
||||||
systemctl enable meshcentral
|
systemctl enable meshagent
|
||||||
systemctl start meshcentral
|
systemctl start meshagent
|
||||||
else
|
else
|
||||||
./meshagent start
|
./meshagent start
|
||||||
ln -s /usr/local/mesh/meshagent /sbin/meshcmd
|
ln -s /usr/local/mesh/meshagent /sbin/meshcmd
|
||||||
|
@ -117,9 +117,9 @@ UninstallAgent() {
|
||||||
|
|
||||||
if [ $starttype -eq 1 ]
|
if [ $starttype -eq 1 ]
|
||||||
then
|
then
|
||||||
rm -f /sbin/meshcmd /lib/systemd/system/meshcentral.service
|
rm -f /sbin/meshcmd /lib/systemd/system/meshagent.service
|
||||||
systemctl disable meshcentral
|
systemctl disable meshagent
|
||||||
systemctl stop meshcentral
|
systemctl stop meshagent
|
||||||
else
|
else
|
||||||
rm -f /sbin/meshcmd /etc/rc2.d/S20mesh /etc/rc3.d/S20mesh /etc/rc5.d/S20mesh
|
rm -f /sbin/meshcmd /etc/rc2.d/S20mesh /etc/rc3.d/S20mesh /etc/rc5.d/S20mesh
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -318,7 +318,7 @@ function lme_heci(options) {
|
||||||
break;
|
break;
|
||||||
case APF_CHANNEL_CLOSE:
|
case APF_CHANNEL_CLOSE:
|
||||||
var rChannelId = chunk.readUInt32BE(1);
|
var rChannelId = chunk.readUInt32BE(1);
|
||||||
if (this.sockets[rChannelId] != undefined) {
|
if ((this.sockets != null) && (this.sockets[rChannelId] != undefined)) {
|
||||||
this.sockets[rChannelId].end();
|
this.sockets[rChannelId].end();
|
||||||
var amtId = this.sockets[rChannelId].lme.amtId;
|
var amtId = this.sockets[rChannelId].lme.amtId;
|
||||||
var buffer = Buffer.alloc(5);
|
var buffer = Buffer.alloc(5);
|
||||||
|
@ -498,6 +498,7 @@ var lmsEvents = {
|
||||||
"iAMT0052-0": "User Notification Alert - KVM session requested.",
|
"iAMT0052-0": "User Notification Alert - KVM session requested.",
|
||||||
"iAMT0052-1": "User Notification Alert - KVM session started.",
|
"iAMT0052-1": "User Notification Alert - KVM session started.",
|
||||||
"iAMT0052-2": "User Notification Alert - KVM session stopped.",
|
"iAMT0052-2": "User Notification Alert - KVM session stopped.",
|
||||||
|
"iAMT0052-3": "User Notification Alert - KVM data channel.",
|
||||||
"iAMT0053": "User Notification Alert - RCS notification.",
|
"iAMT0053": "User Notification Alert - RCS notification.",
|
||||||
"iAMT0053-50": "User Notification Alert - RCS notification (HW button pressed. Connection initiated automatically).",
|
"iAMT0053-50": "User Notification Alert - RCS notification (HW button pressed. Connection initiated automatically).",
|
||||||
"iAMT0053-52": "User Notification Alert - RCS notification (HW button pressed. Connection wasn't initiated automatically).",
|
"iAMT0053-52": "User Notification Alert - RCS notification (HW button pressed. Connection wasn't initiated automatically).",
|
||||||
|
@ -512,7 +513,7 @@ var lmsEvents = {
|
||||||
"iAMT0057": "User Notification Alert - Network State change notification.",
|
"iAMT0057": "User Notification Alert - Network State change notification.",
|
||||||
"iAMT0058": "User Notification Alert - Remote Access change notification.",
|
"iAMT0058": "User Notification Alert - Remote Access change notification.",
|
||||||
"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is closed.",
|
"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is closed.",
|
||||||
//"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is open.",
|
//"iAMT0058-1": "User Notification Alert - Remote Access change notification - tunnel is open.", // TODO
|
||||||
"iAMT0059": "User Notification Alert - KVM enabled event.",
|
"iAMT0059": "User Notification Alert - KVM enabled event.",
|
||||||
"iAMT0059-0": "User Notification Alert - KVM enabled event - KVM disabled.",
|
"iAMT0059-0": "User Notification Alert - KVM enabled event - KVM disabled.",
|
||||||
"iAMT0059-1": "User Notification Alert - KVM enabled event - KVM enabled (both from MEBx and PTNI).",
|
"iAMT0059-1": "User Notification Alert - KVM enabled event - KVM enabled (both from MEBx and PTNI).",
|
||||||
|
|
|
@ -27,74 +27,40 @@ script_functionTable1 = ['nop', 'jump', 'set', 'print', 'dialog', 'getitem', 'su
|
||||||
script_functionTable2 = ['encodeuri', 'decodeuri', 'passwordcheck', 'atob', 'btoa', 'hex2str', 'str2hex', 'random', 'md5', 'maketoarray', 'readshort', 'readshortx', 'readint', 'readsint', 'readintx', 'shorttostr', 'shorttostrx', 'inttostr', 'inttostrx'];
|
script_functionTable2 = ['encodeuri', 'decodeuri', 'passwordcheck', 'atob', 'btoa', 'hex2str', 'str2hex', 'random', 'md5', 'maketoarray', 'readshort', 'readshortx', 'readint', 'readsint', 'readintx', 'shorttostr', 'shorttostrx', 'inttostr', 'inttostrx'];
|
||||||
|
|
||||||
// functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
// functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
||||||
script_functionTableX2 = [encodeURI, decodeURI, passwordcheck, window.atob.bind(window), window.btoa.bind(window), hex2rstr, rstr2hex, random, rstr_md5, MakeToArray, ReadShort, ReadShortX, ReadInt, ReadSInt, ReadIntX, ShortToStr, ShortToStrX, IntToStr, IntToStrX];
|
script_functionTableX2 = [encodeURI, decodeURI, passwordcheck, atob, btoa, hex2rstr, rstr2hex, random, rstr_md5, MakeToArray, ReadShort, ReadShortX, ReadInt, ReadSInt, ReadIntX, ShortToStr, ShortToStrX, IntToStr, IntToStrX];
|
||||||
|
|
||||||
// Optional functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
|
||||||
script_functionTable3 = ['pullsystemstatus', 'pulleventlog', 'pullauditlog', 'pullcertificates', 'pullwatchdog', 'pullsystemdefense', 'pullhardware', 'pulluserinfo', 'pullremoteaccess', 'highlightblock', 'disconnect', 'getsidstring', 'getsidbytearray', 'pulleventsubscriptions'];
|
|
||||||
|
|
||||||
// Optional functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
|
||||||
script_functionTableX3 = [
|
function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; }
|
||||||
PullSystemStatus
|
function ReadShortX(v, p) { return (v[p + 1] << 8) + v[p]; }
|
||||||
,
|
function ReadInt(v, p) { return (v[p] * 0x1000000) + (v[p + 1] << 16) + (v[p + 2] << 8) + v[p + 3]; } // We use "*0x1000000" instead of "<<24" because the shift converts the number to signed int32.
|
||||||
// ###BEGIN###{EventLog}
|
function ReadSInt(v, p) { return (v[p] << 24) + (v[p + 1] << 16) + (v[p + 2] << 8) + v[p + 3]; }
|
||||||
PullEventLog
|
function ReadIntX(v, p) { return (v[p + 3] * 0x1000000) + (v[p + 2] << 16) + (v[p + 1] << 8) + v[p]; }
|
||||||
// ###END###{EventLog}
|
function ShortToStr(v) { return ''; } // TODO
|
||||||
,
|
function ShortToStrX(v) { return ''; } // TODO
|
||||||
// ###BEGIN###{AuditLog}
|
function IntToStr(v) { return ''; } // TODO
|
||||||
PullAuditLog
|
function IntToStrX(v) { return ''; } // TODO
|
||||||
// ###END###{AuditLog}
|
function btoa(x) { return Buffer.from(x).toString('base64'); }
|
||||||
,
|
function atob(x) { var z = null; try { z = Buffer.from(x, 'base64').toString(); } catch (e) { console.log(e); } return z; }
|
||||||
// ###BEGIN###{Certificates}
|
function passwordcheck(p) { if (p.length < 8) return false; var upper = 0, lower = 0, number = 0, nonalpha = 0; for (var i in p) { var c = p.charCodeAt(i); if ((c > 64) && (c < 91)) { upper = 1; } else if ((c > 96) && (c < 123)) { lower = 1; } else if ((c > 47) && (c < 58)) { number = 1; } else { nonalpha = 1; } } return ((upper + lower + number + nonalpha) == 4); }
|
||||||
PullCertificates
|
function hex2rstr(x) { Buffer.from(x, 'hex').toString(); }
|
||||||
// ###END###{Certificates}
|
function rstr2hex(x) { Buffer.from(x).toString('hex'); }
|
||||||
,
|
function random() { return 0; } // TODO
|
||||||
// ###BEGIN###{AgentPresence}
|
function rstr_md5(x) { return null; } // TODO
|
||||||
PullWatchdog
|
|
||||||
// ###END###{AgentPresence}
|
|
||||||
,
|
|
||||||
// ###BEGIN###{SystemDefense}
|
|
||||||
PullSystemDefense
|
|
||||||
// ###END###{SystemDefense}
|
|
||||||
,
|
|
||||||
// ###BEGIN###{HardwareInfo}
|
|
||||||
PullHardware
|
|
||||||
// ###END###{HardwareInfo}
|
|
||||||
,
|
|
||||||
PullUserInfo
|
|
||||||
,
|
|
||||||
// ###BEGIN###{RemoteAccess}
|
|
||||||
PullRemoteAccess
|
|
||||||
// ###END###{RemoteAccess}
|
|
||||||
,
|
|
||||||
// ###BEGIN###{Scripting-Editor}
|
|
||||||
script_HighlightBlock
|
|
||||||
// ###END###{Scripting-Editor}
|
|
||||||
,
|
|
||||||
// ###BEGIN###{ComputerSelector}
|
|
||||||
disconnect
|
|
||||||
// ###END###{ComputerSelector}
|
|
||||||
,
|
|
||||||
function (runner, x) { return GetSidString(x); }
|
|
||||||
,
|
|
||||||
function (runner, x) { return GetSidByteArray(x); }
|
|
||||||
,
|
|
||||||
// ###BEGIN###{EventSubscriptions}
|
|
||||||
PullEventSubscriptions
|
|
||||||
// ###END###{EventSubscriptions}
|
|
||||||
];
|
|
||||||
|
|
||||||
// Setup the script state
|
// Setup the script state
|
||||||
function script_setup(binary, startvars) {
|
module.exports.setup = function(binary, startvars) {
|
||||||
var obj = { startvars:startvars };
|
var obj = { startvars: startvars };
|
||||||
if (binary.length < 6) { console.error('Invalid script length'); return null; } // Script must have at least 6 byte header
|
if (binary.length < 6) { console.error('Invalid script length'); return null; } // Script must have at least 6 byte header
|
||||||
if (ReadInt(binary, 0) != 0x247D2945) { console.error('Invalid binary script'); return null; } // Check the script magic header
|
if (ReadInt(binary, 0) != 0x247D2945) { console.error('Invalid binary script'); return null; } // Check the script magic header
|
||||||
if (ReadShort(binary, 4) > 1) { console.error('Unsupported script version'); return null; } // Check the script version
|
if (ReadShort(binary, 4) > 1) { console.error('Unsupported script version'); return null; } // Check the script version
|
||||||
obj.script = binary.substring(6);
|
obj.script = binary.slice(6);
|
||||||
// obj.onStep;
|
// obj.onStep;
|
||||||
// obj.onConsole;
|
// obj.onConsole;
|
||||||
|
|
||||||
// Reset the script to the start
|
// Reset the script to the start
|
||||||
obj.reset = function (stepspeed) {
|
obj.reset = function (stepspeed) {
|
||||||
|
console.log('reset');
|
||||||
obj.stop();
|
obj.stop();
|
||||||
obj.ip = 0;
|
obj.ip = 0;
|
||||||
obj.variables = startvars;
|
obj.variables = startvars;
|
||||||
|
@ -103,13 +69,15 @@ function script_setup(binary, startvars) {
|
||||||
|
|
||||||
// Start the script
|
// Start the script
|
||||||
obj.start = function (stepspeed) {
|
obj.start = function (stepspeed) {
|
||||||
|
console.log('start');
|
||||||
obj.stop();
|
obj.stop();
|
||||||
obj.stepspeed = stepspeed;
|
if (stepspeed == null) { obj.stepspeed = 100; } else { obj.stepspeed = stepspeed; }
|
||||||
if (stepspeed > 0) { obj.timer = setInterval(function () { obj.step() }, stepspeed); }
|
if (obj.stepspeed > 0) { obj.timer = setInterval(function () { obj.step() }, obj.stepspeed); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the script
|
// Stop the script
|
||||||
obj.stop = function () {
|
obj.stop = function () {
|
||||||
|
console.log('stop');
|
||||||
if (obj.timer != null) { clearInterval(obj.timer); }
|
if (obj.timer != null) { clearInterval(obj.timer); }
|
||||||
obj.timer = null;
|
obj.timer = null;
|
||||||
obj.stepspeed = 0;
|
obj.stepspeed = 0;
|
||||||
|
@ -123,6 +91,7 @@ function script_setup(binary, startvars) {
|
||||||
|
|
||||||
// Run the script one step forward
|
// Run the script one step forward
|
||||||
obj.step = function () {
|
obj.step = function () {
|
||||||
|
console.log('step');
|
||||||
if (obj.state != 1) return;
|
if (obj.state != 1) return;
|
||||||
if (obj.ip < obj.script.length) {
|
if (obj.ip < obj.script.length) {
|
||||||
var cmdid = ReadShort(obj.script, obj.ip);
|
var cmdid = ReadShort(obj.script, obj.ip);
|
||||||
|
@ -133,11 +102,11 @@ function script_setup(binary, startvars) {
|
||||||
|
|
||||||
// Clear all temp variables (This is optional)
|
// Clear all temp variables (This is optional)
|
||||||
for (var i in obj.variables) { if (i.startsWith('__')) { delete obj.variables[i]; } }
|
for (var i in obj.variables) { if (i.startsWith('__')) { delete obj.variables[i]; } }
|
||||||
|
|
||||||
// Loop on each argument, moving forward by the argument length each time
|
// Loop on each argument, moving forward by the argument length each time
|
||||||
for (var i = 0; i < argcount; i++) {
|
for (var i = 0; i < argcount; i++) {
|
||||||
var arglen = ReadShort(obj.script, argptr);
|
var arglen = ReadShort(obj.script, argptr);
|
||||||
var argval = obj.script.substring(argptr + 2, argptr + 2 + arglen);
|
var argval = obj.script.substring(argptr + 2, argptr + 2 + arglen); // <----------- Problem area
|
||||||
var argtyp = argval.charCodeAt(0);
|
var argtyp = argval.charCodeAt(0);
|
||||||
argval = argval.substring(1);
|
argval = argval.substring(1);
|
||||||
if (argtyp < 2) {
|
if (argtyp < 2) {
|
||||||
|
@ -152,7 +121,7 @@ function script_setup(binary, startvars) {
|
||||||
}
|
}
|
||||||
argptr += (2 + arglen);
|
argptr += (2 + arglen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move instruction pointer forward by command size
|
// Move instruction pointer forward by command size
|
||||||
obj.ip += cmdlen;
|
obj.ip += cmdlen;
|
||||||
|
|
||||||
|
@ -277,12 +246,12 @@ function script_setup(binary, startvars) {
|
||||||
} else {
|
} else {
|
||||||
if (cmdid < 20000) {
|
if (cmdid < 20000) {
|
||||||
// functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
// functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
||||||
storeInArg0 = script_functionTableX2[cmdid - 10000](argsval[1], argsval[2], argsval[3], argsval[4], argsval[5], argsval[6]);
|
//storeInArg0 = script_functionTableX2[cmdid - 10000](argsval[1], argsval[2], argsval[3], argsval[4], argsval[5], argsval[6]);
|
||||||
} else {
|
} else {
|
||||||
// Optional functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
// Optional functions of type ARG1 = func(ARG2, ARG3, ARG4, ARG5, ARG6)
|
||||||
if (script_functionTableX3 && script_functionTableX3[cmdid - 20000]) {
|
//if (script_functionTableX3 && script_functionTableX3[cmdid - 20000]) {
|
||||||
storeInArg0 = script_functionTableX3[cmdid - 20000](obj, argsval[1], argsval[2], argsval[3], argsval[4], argsval[5], argsval[6]); // Note that optional calls start with "obj" as first argument.
|
// storeInArg0 = script_functionTableX3[cmdid - 20000](obj, argsval[1], argsval[2], argsval[3], argsval[4], argsval[5], argsval[6]); // Note that optional calls start with "obj" as first argument.
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +318,7 @@ function script_setup(binary, startvars) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Argument types: 0 = Variable, 1 = String, 2 = Integer, 3 = Label
|
// Argument types: 0 = Variable, 1 = String, 2 = Integer, 3 = Label
|
||||||
function script_compile(script, onmsg) {
|
module.exports.compile = function(script, onmsg) {
|
||||||
var r = '', scriptlines = script.split('\n'), labels = {}, labelswap = [], swaps = [];
|
var r = '', scriptlines = script.split('\n'), labels = {}, labelswap = [], swaps = [];
|
||||||
// Go thru each script line and encode it
|
// Go thru each script line and encode it
|
||||||
for (var i in scriptlines) {
|
for (var i in scriptlines) {
|
||||||
|
@ -362,7 +331,6 @@ function script_compile(script, onmsg) {
|
||||||
if (scriptline[0] == ':') { labels[keywords[0].toUpperCase()] = r.length; continue; } // Mark a label position
|
if (scriptline[0] == ':') { labels[keywords[0].toUpperCase()] = r.length; continue; } // Mark a label position
|
||||||
var funcIndex = script_functionTable1.indexOf(keywords[0].toLowerCase());
|
var funcIndex = script_functionTable1.indexOf(keywords[0].toLowerCase());
|
||||||
if (funcIndex == -1) { funcIndex = script_functionTable2.indexOf(keywords[0].toLowerCase()); if (funcIndex >= 0) funcIndex += 10000; }
|
if (funcIndex == -1) { funcIndex = script_functionTable2.indexOf(keywords[0].toLowerCase()); if (funcIndex >= 0) funcIndex += 10000; }
|
||||||
if (funcIndex == -1) { funcIndex = script_functionTable3.indexOf(keywords[0].toLowerCase()); if (funcIndex >= 0) funcIndex += 20000; } // Optional methods
|
|
||||||
if (funcIndex == -1) { if (onmsg) { onmsg("Unabled to compile, unknown command: " + keywords[0]); } return ''; }
|
if (funcIndex == -1) { if (onmsg) { onmsg("Unabled to compile, unknown command: " + keywords[0]); } return ''; }
|
||||||
// Encode CommandId, CmdSize, ArgCount, Arg1Len, Arg1, Arg2Len, Arg2...
|
// Encode CommandId, CmdSize, ArgCount, Arg1Len, Arg1, Arg2Len, Arg2...
|
||||||
var cmd = ShortToStr(keywords.length - 1);
|
var cmd = ShortToStr(keywords.length - 1);
|
||||||
|
@ -397,7 +365,7 @@ function script_compile(script, onmsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompile the script, intended for debugging only
|
// Decompile the script, intended for debugging only
|
||||||
function script_decompile(binary, onecmd) {
|
module.exports.decompile = function(binary, onecmd) {
|
||||||
var r = '', ptr = 6, labelcount = 0, labels = {};
|
var r = '', ptr = 6, labelcount = 0, labels = {};
|
||||||
if (onecmd >= 0) {
|
if (onecmd >= 0) {
|
||||||
ptr = onecmd; // If we are decompiling just one command, set the ptr to that command.
|
ptr = onecmd; // If we are decompiling just one command, set the ptr to that command.
|
||||||
|
@ -436,11 +404,7 @@ function script_decompile(binary, onecmd) {
|
||||||
if (cmdid < 10000) {
|
if (cmdid < 10000) {
|
||||||
r += script_functionTable1[cmdid] + argstr + "\n";
|
r += script_functionTable1[cmdid] + argstr + "\n";
|
||||||
} else {
|
} else {
|
||||||
if (cmdid >= 20000) {
|
if ((cmdid >= 10000) && (cmdid < 10000)) { r += script_functionTable2[cmdid - 10000] + argstr + "\n"; }
|
||||||
r += script_functionTable3[cmdid - 20000] + argstr + "\n"; // Optional methods
|
|
||||||
} else {
|
|
||||||
r += script_functionTable2[cmdid - 10000] + argstr + "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ptr += cmdlen;
|
ptr += cmdlen;
|
||||||
if (onecmd >= 0) return r; // If we are decompiling just one command, exit now
|
if (onecmd >= 0) return r; // If we are decompiling just one command, exit now
|
||||||
|
|
|
@ -438,10 +438,10 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
|
||||||
if (len < 9) return 0;
|
if (len < 9) return 0;
|
||||||
var RecipientChannel = common.ReadInt(data, 1);
|
var RecipientChannel = common.ReadInt(data, 1);
|
||||||
var ByteToAdd = common.ReadInt(data, 5);
|
var ByteToAdd = common.ReadInt(data, 5);
|
||||||
Debug(3, 'MPS:CHANNEL_WINDOW_ADJUST', RecipientChannel, ByteToAdd);
|
|
||||||
var cirachannel = socket.tag.channels[RecipientChannel];
|
var cirachannel = socket.tag.channels[RecipientChannel];
|
||||||
if (cirachannel == undefined) { console.log("MPS Error in CHANNEL_WINDOW_ADJUST: Unable to find channelid " + RecipientChannel); return; }
|
if (cirachannel == undefined) { console.log("MPS Error in CHANNEL_WINDOW_ADJUST: Unable to find channelid " + RecipientChannel); return; }
|
||||||
cirachannel.sendcredits += ByteToAdd;
|
cirachannel.sendcredits += ByteToAdd;
|
||||||
|
Debug(3, 'MPS:CHANNEL_WINDOW_ADJUST', RecipientChannel, ByteToAdd, cirachannel.sendcredits);
|
||||||
if (cirachannel.state == 2 && cirachannel.sendBuffer != undefined) {
|
if (cirachannel.state == 2 && cirachannel.sendBuffer != undefined) {
|
||||||
// Compute how much data we can send
|
// Compute how much data we can send
|
||||||
if (cirachannel.sendBuffer.length <= cirachannel.sendcredits) {
|
if (cirachannel.sendBuffer.length <= cirachannel.sendcredits) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.1.3-v",
|
"version": "0.1.3-x",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
|
|
@ -224,7 +224,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
|
||||||
if (obj.onDisplayinfo != null) { obj.onDisplayinfo(obj, myOptions, selitem); }
|
if (obj.onDisplayinfo != null) { obj.onDisplayinfo(obj, myOptions, selitem); }
|
||||||
break;
|
break;
|
||||||
case 12: // SetDisplay
|
case 12: // SetDisplay
|
||||||
console.log('SetDisplayConfirm');
|
//console.log('SetDisplayConfirmed');
|
||||||
break;
|
break;
|
||||||
case 14: // KVM_INIT_TOUCH
|
case 14: // KVM_INIT_TOUCH
|
||||||
obj.touchenabled = 1;
|
obj.touchenabled = 1;
|
||||||
|
|
|
@ -52,6 +52,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||||
obj.xxOnControlCommand = function (msg) {
|
obj.xxOnControlCommand = function (msg) {
|
||||||
var controlMsg;
|
var controlMsg;
|
||||||
try { controlMsg = JSON.parse(msg); } catch (e) { return; }
|
try { controlMsg = JSON.parse(msg); } catch (e) { return; }
|
||||||
|
//console.log(controlMsg);
|
||||||
if (obj.webrtc != null) {
|
if (obj.webrtc != null) {
|
||||||
if (controlMsg.type == 'answer') {
|
if (controlMsg.type == 'answer') {
|
||||||
obj.webrtc.setRemoteDescription(new RTCSessionDescription(controlMsg), function () { /*console.log('WebRTC remote ok');*/ }, obj.xxCloseWebRTC);
|
obj.webrtc.setRemoteDescription(new RTCSessionDescription(controlMsg), function () { /*console.log('WebRTC remote ok');*/ }, obj.xxCloseWebRTC);
|
||||||
|
@ -93,7 +94,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||||
// TODO: Hold/Stop sending data over websocket
|
// TODO: Hold/Stop sending data over websocket
|
||||||
if (obj.onStateChanged != null) { obj.onStateChanged(obj, obj.State); }
|
if (obj.onStateChanged != null) { obj.onStateChanged(obj, obj.State); }
|
||||||
};
|
};
|
||||||
obj.webchannel.onclose = function (event) { console.log('WebRTC close'); obj.Stop(); }
|
obj.webchannel.onclose = function (event) { /*console.log('WebRTC close');*/ obj.Stop(); }
|
||||||
obj.webrtc.onicecandidate = function (e) {
|
obj.webrtc.onicecandidate = function (e) {
|
||||||
if (e.candidate == null) {
|
if (e.candidate == null) {
|
||||||
obj.socket.send(JSON.stringify(obj.webrtcoffer)); // End of candidates, send the offer
|
obj.socket.send(JSON.stringify(obj.webrtcoffer)); // End of candidates, send the offer
|
||||||
|
@ -101,7 +102,12 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
|
||||||
obj.webrtcoffer.sdp += ("a=" + e.candidate.candidate + "\r\n"); // New candidate, add it to the SDP
|
obj.webrtcoffer.sdp += ("a=" + e.candidate.candidate + "\r\n"); // New candidate, add it to the SDP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj.webrtc.oniceconnectionstatechange = function () { if (obj.webrtc != null) { if ((obj.webrtc.iceConnectionState == 'disconnected') || (obj.webrtc.iceConnectionState == 'failed')) { obj.xxCloseWebRTC(); } } }
|
obj.webrtc.oniceconnectionstatechange = function () {
|
||||||
|
if (obj.webrtc != null) {
|
||||||
|
//console.log(obj.webrtc.iceConnectionState)
|
||||||
|
if ((obj.webrtc.iceConnectionState == 'disconnected') || (obj.webrtc.iceConnectionState == 'failed')) { obj.xxCloseWebRTC(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
obj.webrtc.createOffer(function (offer) {
|
obj.webrtc.createOffer(function (offer) {
|
||||||
// Got the offer
|
// Got the offer
|
||||||
obj.webrtcoffer = offer;
|
obj.webrtcoffer = offer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue