mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 07:57:56 +03:00
Many fixes with desktop recording indexor and player.
This commit is contained in:
parent
3eacf00ea5
commit
076b5089f4
44
mcrec.js
44
mcrec.js
@ -113,13 +113,13 @@ function processBlock(state, block, err) {
|
||||
// MeshCentral Remote Desktop
|
||||
// TODO
|
||||
if (block.data.length >= 4) {
|
||||
var command = block.data.readInt16BE(0);
|
||||
var cmdsize = block.data.readInt16BE(2);
|
||||
var command = block.data.readUInt16BE(0);
|
||||
var cmdsize = block.data.readUInt16BE(2);
|
||||
if ((command == 27) && (cmdsize == 8)) {
|
||||
// Jumbo packet
|
||||
if (block.data.length >= 12) {
|
||||
command = block.data.readInt16BE(8);
|
||||
cmdsize = block.data.readInt32BE(4);
|
||||
command = block.data.readUInt16BE(8);
|
||||
cmdsize = block.data.readUInt32BE(4);
|
||||
if (block.data.length == (cmdsize + 8)) {
|
||||
block.data = block.data.slice(8, block.data.length);
|
||||
} else {
|
||||
@ -131,8 +131,8 @@ function processBlock(state, block, err) {
|
||||
|
||||
switch (command) {
|
||||
case 3: // Tile
|
||||
var x = block.data.readInt16BE(4);
|
||||
var y = block.data.readInt16BE(6);
|
||||
var x = block.data.readUInt16BE(4);
|
||||
var y = block.data.readUInt16BE(6);
|
||||
var dimensions = require('image-size')(block.data.slice(8));
|
||||
//log("Tile", x, y, dimensions.width, dimensions.height, block.ptr);
|
||||
//console.log(elapseSeconds);
|
||||
@ -148,13 +148,13 @@ function processBlock(state, block, err) {
|
||||
|
||||
break;
|
||||
case 4: // Tile copy
|
||||
var x = block.data.readInt16BE(4);
|
||||
var y = block.data.readInt16BE(6);
|
||||
var x = block.data.readUInt16BE(4);
|
||||
var y = block.data.readUInt16BE(6);
|
||||
//log("TileCopy", x, y);
|
||||
break;
|
||||
case 7: // Screen Size, clear the screen state and computer the tile count
|
||||
state.width = block.data.readInt16BE(4);
|
||||
state.height = block.data.readInt16BE(6);
|
||||
state.width = block.data.readUInt16BE(4);
|
||||
state.height = block.data.readUInt16BE(6);
|
||||
state.swidth = state.width / 16;
|
||||
state.sheight = state.height / 16;
|
||||
if (Math.floor(state.swidth) != state.swidth) { state.swidth = Math.floor(state.swidth) + 1; }
|
||||
@ -232,20 +232,20 @@ function recordingEntry(fd, type, flags, time, data, func, tag, position) {
|
||||
function readLastBlock(state, func) {
|
||||
var buf = Buffer.alloc(32);
|
||||
fs.read(state.recFile, buf, 0, 32, state.recFileSize - 32, function (err, bytesRead, buf) {
|
||||
var type = buf.readInt16BE(0);
|
||||
var flags = buf.readInt16BE(2);
|
||||
var size = buf.readInt32BE(4);
|
||||
var time = (buf.readInt32BE(8) << 32) + buf.readInt32BE(12);
|
||||
var type = buf.readUInt16BE(0);
|
||||
var flags = buf.readUInt16BE(2);
|
||||
var size = buf.readUInt32BE(4);
|
||||
var time = (buf.readUInt32BE(8) << 32) + buf.readUInt32BE(12);
|
||||
var magic = buf.toString('utf8', 16, 32);
|
||||
if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) {
|
||||
// Extra metadata present, lets read it.
|
||||
extraMetadata = null;
|
||||
var buf2 = Buffer.alloc(16);
|
||||
fs.read(state.recFile, buf2, 0, 16, time, function (err, bytesRead, buf2) {
|
||||
var xtype = buf2.readInt16BE(0);
|
||||
var xflags = buf2.readInt16BE(2);
|
||||
var xsize = buf2.readInt32BE(4);
|
||||
var xtime = (buf2.readInt32BE(8) << 32) + buf.readInt32BE(12);
|
||||
var xtype = buf2.readUInt16BE(0);
|
||||
var xflags = buf2.readUInt16BE(2);
|
||||
var xsize = buf2.readUInt32BE(4);
|
||||
var xtime = (buf2.readUInt32BE(8) << 32) + buf.readUInt32BE(12);
|
||||
var buf3 = Buffer.alloc(xsize);
|
||||
fs.read(state.recFile, buf3, 0, xsize, time + 16, function (err, bytesRead, buf3) {
|
||||
func(state, true, xtime, JSON.parse(buf3.toString()));
|
||||
@ -263,10 +263,10 @@ function readNextBlock(state, func) {
|
||||
var r = {}, buf = Buffer.alloc(16);
|
||||
fs.read(state.recFile, buf, 0, 16, state.recFilePtr, function (err, bytesRead, buf) {
|
||||
if (bytesRead != 16) { func(state, null, true); return; } // Error
|
||||
r.type = buf.readInt16BE(0);
|
||||
r.flags = buf.readInt16BE(2);
|
||||
r.size = buf.readInt32BE(4);
|
||||
r.time = buf.readIntBE(8, 8);
|
||||
r.type = buf.readUInt16BE(0);
|
||||
r.flags = buf.readUInt16BE(2);
|
||||
r.size = buf.readUInt32BE(4);
|
||||
r.time = buf.readUIntBE(8, 8);
|
||||
r.date = new Date(r.time);
|
||||
r.ptr = state.recFilePtr;
|
||||
if ((state.recFilePtr + 16 + r.size) > state.recFileSize) { func(state, null, true); return; } // Error
|
||||
|
24
meshrelay.js
24
meshrelay.js
@ -330,17 +330,6 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
if (relayinfo.state == 2) {
|
||||
var peer = (relayinfo.peer1 == obj) ? relayinfo.peer2 : relayinfo.peer1;
|
||||
|
||||
// Close the recording file
|
||||
if (ws.logfile != null) {
|
||||
recordingEntry(ws.logfile.fd, 3, 0, 'MeshCentralMCREC', function (fd, tag) {
|
||||
parent.parent.fs.close(fd);
|
||||
tag.ws.logfile = null;
|
||||
tag.pws.logfile = null;
|
||||
// Now that the recording file is closed, check if we need to index this file.
|
||||
if (domain.sessionrecording.index !== false) { parent.parent.certificateOperations.acceleratorPerformOperation('indexMcRec', tag.logfile.filename); }
|
||||
}, { ws: ws, pws: peer.ws, logfile: ws.logfile });
|
||||
}
|
||||
|
||||
// Disconnect the peer
|
||||
try { if (peer.relaySessionCounted) { parent.relaySessionCount--; delete peer.relaySessionCounted; } } catch (ex) { console.log(ex); }
|
||||
parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(obj.req.ip) + ' --> ' + cleanRemoteAddr(peer.req.ip) + ')');
|
||||
@ -369,6 +358,19 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
} else {
|
||||
parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(obj.req.ip) + ')');
|
||||
}
|
||||
|
||||
// Close the recording file if needed
|
||||
if (ws.logfile != null) {
|
||||
var logfile = ws.logfile;
|
||||
delete ws.logfile;
|
||||
if (peer.ws) { delete peer.ws.logfile; }
|
||||
recordingEntry(logfile.fd, 3, 0, 'MeshCentralMCREC', function (fd, tag) {
|
||||
parent.parent.fs.close(fd);
|
||||
// Now that the recording file is closed, check if we need to index this file.
|
||||
if (domain.sessionrecording.index !== false) { parent.parent.certificateOperations.acceleratorPerformOperation('indexMcRec', tag.logfile.filename); }
|
||||
}, { ws: ws, pws: peer.ws, logfile: logfile });
|
||||
}
|
||||
|
||||
try { ws.close(); } catch (ex) { }
|
||||
delete parent.wsrelays[obj.id];
|
||||
}
|
||||
|
@ -113,7 +113,8 @@ module.exports.CreateRedirServer = function (parent, db, args, func) {
|
||||
if (parent.config.domains[i].dns != null) { continue; }
|
||||
var url = parent.config.domains[i].url;
|
||||
obj.app.get(url, performRedirection); // Root redirection
|
||||
obj.app.use(url + "clickonce", obj.express.static(obj.parent.path.join(__dirname, "public/clickonce"))); // Indicates the clickonce folder is public
|
||||
obj.app.get(url + 'player.htm', performRedirection); // Player redirection
|
||||
obj.app.use(url + 'clickonce', obj.express.static(obj.parent.path.join(__dirname, "public/clickonce"))); // Indicates the clickonce folder is public
|
||||
|
||||
// Setup all of the redirections to HTTPS
|
||||
const redirections = ['terms', 'logout', 'MeshServerRootCert.cer', 'mescript.ashx', 'checkmail', 'agentinvite', 'messenger', 'meshosxagent', 'devicepowerevents.ashx', 'downloadfile.ashx', 'userfiles/*', 'webrelay.ashx', 'health.ashx', 'logo.png', 'welcome.jpg'];
|
||||
|
@ -288,7 +288,9 @@
|
||||
if ((playing == false) && (forced !== true)) return;
|
||||
var flagBinary = (flags & 1) != 0, flagUser = (flags & 2) != 0;
|
||||
|
||||
if (type == 2) {
|
||||
// Update the clock
|
||||
recFileLastTime = time;
|
||||
var deltaTimeTotalSec = Math.floor((time - recFileStartTime) / 1000);
|
||||
if (currentDeltaTimeTotalSec != deltaTimeTotalSec) {
|
||||
// Hours, minutes and seconds
|
||||
@ -298,6 +300,7 @@
|
||||
var secs = Math.floor(deltaTimeTotalSec % 60);
|
||||
QH('timespan', pad2(hrs) + ':' + pad2(mins) + ':' + pad2(secs))
|
||||
}
|
||||
}
|
||||
|
||||
if ((type == 2) && flagBinary && !flagUser) {
|
||||
// Device --> User data
|
||||
@ -325,7 +328,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
recFileLastTime = time;
|
||||
if (playing) { readNextBlock(processBlock); }
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user