mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Fixed desktop & terminal recording.
This commit is contained in:
parent
f6dfd435fa
commit
8e1fc021c7
42
mcrec.js
42
mcrec.js
@ -189,10 +189,10 @@ function writeIndex(state, func) {
|
|||||||
extraMetadata.indexInterval = state.indexTime;
|
extraMetadata.indexInterval = state.indexTime;
|
||||||
extraMetadata.indexStartTime = state.startTime;
|
extraMetadata.indexStartTime = state.startTime;
|
||||||
extraMetadata.indexes = state.indexes;
|
extraMetadata.indexes = state.indexes;
|
||||||
recordingEntry(state.recFile, 4, 0, state.lastTimeStamp, JSON.stringify(extraMetadata), function (state) {
|
recordingEntry(state.recFile, 4, 0, state.lastTimeStamp, JSON.stringify(extraMetadata), function (state, len) {
|
||||||
recordingEntry(state.recFile, 3, 0, state.recFileSize - 32, 'MeshCentralMCNDX', function (state) {
|
recordingEntry(state.recFile, 3, 0, state.recFileSize - 32, 'MeshCentralMCNDX', function (state) {
|
||||||
func(state);
|
func(state);
|
||||||
}, state);
|
}, state, state.recFileSize - 32 + len);
|
||||||
}, state, state.recFileSize - 32);
|
}, state, state.recFileSize - 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,50 +202,50 @@ function recordingEntry(fd, type, flags, time, data, func, tag, position) {
|
|||||||
if (typeof data == 'string') {
|
if (typeof data == 'string') {
|
||||||
// String write
|
// String write
|
||||||
var blockData = Buffer.from(data), header = Buffer.alloc(16); // Header: Type (2) + Flags (2) + Size(4) + Time(8)
|
var blockData = Buffer.from(data), header = Buffer.alloc(16); // Header: Type (2) + Flags (2) + Size(4) + Time(8)
|
||||||
header.writeInt16BE(type, 0); // Type (1 = Header, 2 = Network Data)
|
header.writeInt16BE(type, 0); // Type (1 = Header, 2 = Network Data, 3 = End, 4 = Extra Metadata)
|
||||||
header.writeInt16BE(flags, 2); // Flags (1 = Binary, 2 = User)
|
header.writeInt16BE(flags, 2); // Flags (1 = Binary, 2 = User)
|
||||||
header.writeInt32BE(blockData.length, 4); // Size
|
header.writeInt32BE(blockData.length, 4); // Size
|
||||||
header.writeIntBE(time, 10, 6); // Time
|
header.writeIntBE(time, 10, 6); // Time
|
||||||
var block = Buffer.concat([header, blockData]);
|
var block = Buffer.concat([header, blockData]);
|
||||||
if (typeof position == 'number') {
|
if (typeof position == 'number') {
|
||||||
fs.write(fd, block, 0, block.length, position, function () { func(tag); });
|
fs.write(fd, block, 0, block.length, position, function () { func(tag, block.length); });
|
||||||
} else {
|
} else {
|
||||||
fs.write(fd, block, 0, block.length, function () { func(tag); });
|
fs.write(fd, block, 0, block.length, function () { func(tag, block.length); });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Binary write
|
// Binary write
|
||||||
var header = Buffer.alloc(16); // Header: Type (2) + Flags (2) + Size(4) + Time(8)
|
var header = Buffer.alloc(16); // Header: Type (2) + Flags (2) + Size(4) + Time(8)
|
||||||
header.writeInt16BE(type, 0); // Type (1 = Header, 2 = Network Data)
|
header.writeInt16BE(type, 0); // Type (1 = Header, 2 = Network Data, 3 = End, 4 = Extra Metadata)
|
||||||
header.writeInt16BE(flags | 1, 2); // Flags (1 = Binary, 2 = User)
|
header.writeInt16BE(flags | 1, 2); // Flags (1 = Binary, 2 = User)
|
||||||
header.writeInt32BE(data.length, 4); // Size
|
header.writeInt32BE(data.length, 4); // Size
|
||||||
header.writeIntBE(time, 10, 6); // Time
|
header.writeIntBE(time, 10, 6); // Time
|
||||||
var block = Buffer.concat([header, data]);
|
var block = Buffer.concat([header, data]);
|
||||||
if (typeof position == 'number') {
|
if (typeof position == 'number') {
|
||||||
fs.write(fd, block, 0, block.length, position, function () { func(tag); });
|
fs.write(fd, block, 0, block.length, position, function () { func(tag, block.length); });
|
||||||
} else {
|
} else {
|
||||||
fs.write(fd, block, 0, block.length, function () { func(tag); });
|
fs.write(fd, block, 0, block.length, function () { func(tag, block.length); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ex) { console.log(ex); func(state, tag); }
|
} catch (ex) { console.log(ex); func(tag); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function readLastBlock(state, func) {
|
function readLastBlock(state, func) {
|
||||||
var buf = Buffer.alloc(32);
|
var buf = Buffer.alloc(32);
|
||||||
fs.read(state.recFile, buf, 0, 32, state.recFileSize - 32, function (err, bytesRead, buf) {
|
fs.read(state.recFile, buf, 0, 32, state.recFileSize - 32, function (err, bytesRead, buf) {
|
||||||
var type = buf.readUInt16BE(0);
|
var type = buf.readUInt16BE(0); // Type (1 = Header, 2 = Network Data)
|
||||||
var flags = buf.readUInt16BE(2);
|
var flags = buf.readUInt16BE(2); // Flags (1 = Binary, 2 = User)
|
||||||
var size = buf.readUInt32BE(4);
|
var size = buf.readUInt32BE(4); // Size
|
||||||
var time = (buf.readUInt32BE(8) << 32) + buf.readUInt32BE(12);
|
var time = buf.readUIntBE(10, 6); // Time
|
||||||
var magic = buf.toString('utf8', 16, 32);
|
var magic = buf.toString('utf8', 16, 32);
|
||||||
if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) {
|
if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) {
|
||||||
// Extra metadata present, lets read it.
|
// Extra metadata present, lets read it.
|
||||||
extraMetadata = null;
|
extraMetadata = null;
|
||||||
var buf2 = Buffer.alloc(16);
|
var buf2 = Buffer.alloc(16);
|
||||||
fs.read(state.recFile, buf2, 0, 16, time, function (err, bytesRead, buf2) {
|
fs.read(state.recFile, buf2, 0, 16, time, function (err, bytesRead, buf2) {
|
||||||
var xtype = buf2.readUInt16BE(0);
|
var xtype = buf2.readUInt16BE(0); // Type (1 = Header, 2 = Network Data, 3 = End, 4 = Extra Metadata)
|
||||||
var xflags = buf2.readUInt16BE(2);
|
var xflags = buf2.readUInt16BE(2); // Flags (1 = Binary, 2 = User)
|
||||||
var xsize = buf2.readUInt32BE(4);
|
var xsize = buf2.readUInt32BE(4); // Size
|
||||||
var xtime = (buf2.readUInt32BE(8) << 32) + buf.readUInt32BE(12);
|
var xtime = buf.readUIntBE(10, 6); // Time
|
||||||
var buf3 = Buffer.alloc(xsize);
|
var buf3 = Buffer.alloc(xsize);
|
||||||
fs.read(state.recFile, buf3, 0, xsize, time + 16, function (err, bytesRead, buf3) {
|
fs.read(state.recFile, buf3, 0, xsize, time + 16, function (err, bytesRead, buf3) {
|
||||||
func(state, true, xtime, JSON.parse(buf3.toString()));
|
func(state, true, xtime, JSON.parse(buf3.toString()));
|
||||||
@ -264,10 +264,10 @@ function readNextBlock(state, func) {
|
|||||||
fs.read(state.recFile, buf, 0, 16, state.recFilePtr, function (err, bytesRead, buf) {
|
fs.read(state.recFile, buf, 0, 16, state.recFilePtr, function (err, bytesRead, buf) {
|
||||||
if (bytesRead != 16) { func(state, null, true); return; } // Error
|
if (bytesRead != 16) { func(state, null, true); return; } // Error
|
||||||
try {
|
try {
|
||||||
r.type = buf.readUInt16BE(0);
|
r.type = buf.readUInt16BE(0); // Type (1 = Header, 2 = Network Data, 3 = End, 4 = Extra Metadata)
|
||||||
r.flags = buf.readUInt16BE(2);
|
r.flags = buf.readUInt16BE(2); // Flags (1 = Binary, 2 = User)
|
||||||
r.size = buf.readUInt32BE(4);
|
r.size = buf.readUInt32BE(4); // Size
|
||||||
r.time = buf.readUIntBE(8, 8);
|
r.time = buf.readUIntBE(10, 6); // Time
|
||||||
r.date = new Date(r.time);
|
r.date = new Date(r.time);
|
||||||
r.ptr = state.recFilePtr;
|
r.ptr = state.recFilePtr;
|
||||||
if ((state.recFilePtr + 16 + r.size) > state.recFileSize) { func(state, null, true); return; } // Error
|
if ((state.recFilePtr + 16 + r.size) > state.recFileSize) { func(state, null, true); return; } // Error
|
||||||
|
@ -227,7 +227,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||||||
var metadata = { magic: 'MeshCentralRelaySession', ver: 1, userid: sessionUser._id, username: sessionUser.name, sessionid: obj.id, ipaddr1: cleanRemoteAddr(obj.req.ip), ipaddr2: cleanRemoteAddr(obj.peer.req.ip), time: new Date().toLocaleString(), protocol: (((obj.req == null) || (obj.req.query == null)) ? null : obj.req.query.p), nodeid: (((obj.req == null) || (obj.req.query == null)) ? null : obj.req.query.nodeid ) };
|
var metadata = { magic: 'MeshCentralRelaySession', ver: 1, userid: sessionUser._id, username: sessionUser.name, sessionid: obj.id, ipaddr1: cleanRemoteAddr(obj.req.ip), ipaddr2: cleanRemoteAddr(obj.peer.req.ip), time: new Date().toLocaleString(), protocol: (((obj.req == null) || (obj.req.query == null)) ? null : obj.req.query.p), nodeid: (((obj.req == null) || (obj.req.query == null)) ? null : obj.req.query.nodeid ) };
|
||||||
if (xdevicename2 != null) { metadata.devicename = xdevicename2; }
|
if (xdevicename2 != null) { metadata.devicename = xdevicename2; }
|
||||||
var firstBlock = JSON.stringify(metadata);
|
var firstBlock = JSON.stringify(metadata);
|
||||||
recordingEntry(fd, 1, ((obj.req.query.browser) ? 2 : 0), firstBlock, function () {
|
recordingEntry(fd, 1, 0, firstBlock, function () {
|
||||||
try { relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false, filename: recFullFilename }; } catch (ex) {
|
try { relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false, filename: recFullFilename }; } catch (ex) {
|
||||||
try { ws.send('c'); } catch (ex) { } // Send connect to both peers, 'cr' indicates the session is being recorded.
|
try { ws.send('c'); } catch (ex) { } // Send connect to both peers, 'cr' indicates the session is being recorded.
|
||||||
try { relayinfo.peer1.ws.send('c'); } catch (ex) { }
|
try { relayinfo.peer1.ws.send('c'); } catch (ex) { }
|
||||||
|
@ -37,7 +37,10 @@
|
|||||||
"express": "^4.17.0",
|
"express": "^4.17.0",
|
||||||
"express-handlebars": "^3.1.0",
|
"express-handlebars": "^3.1.0",
|
||||||
"express-ws": "^4.0.0",
|
"express-ws": "^4.0.0",
|
||||||
|
"html-minifier": "^4.0.0",
|
||||||
"ipcheck": "^0.1.0",
|
"ipcheck": "^0.1.0",
|
||||||
|
"jsdom": "^16.2.1",
|
||||||
|
"minify-js": "0.0.4",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"multiparty": "^4.2.1",
|
"multiparty": "^4.2.1",
|
||||||
"nedb": "^1.8.0",
|
"nedb": "^1.8.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
CD ..\translate
|
CD ..\translate
|
||||||
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js minifyall
|
%LOCALAPPDATA%\..\Roaming\nvm\v12.13.0\node64 translate.js minifyall
|
||||||
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js translateall
|
%LOCALAPPDATA%\..\Roaming\nvm\v12.13.0\node64 translate.js translateall
|
||||||
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js extractall
|
%LOCALAPPDATA%\..\Roaming\nvm\v12.13.0\node64 translate.js extractall
|
||||||
|
@ -21570,14 +21570,14 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"en": "{0} second{1}",
|
|
||||||
"nl": "{0} seconde{1}",
|
|
||||||
"es": "{0} second{1}",
|
|
||||||
"de": "{0} Sekunde{1}",
|
|
||||||
"cs": "{0} sekund{1}",
|
"cs": "{0} sekund{1}",
|
||||||
"pt": "{0} segundo{1}",
|
"de": "{0} Sekunde{1}",
|
||||||
|
"en": "{0} second{1}",
|
||||||
|
"es": "{0} second{1}",
|
||||||
"fr": "{0} seconde{1}",
|
"fr": "{0} seconde{1}",
|
||||||
"ja": "{0} 秒{1}",
|
"ja": "{0} 秒{1}",
|
||||||
|
"nl": "{0} seconde{1}",
|
||||||
|
"pt": "{0} segundo{1}",
|
||||||
"ru": "{0} секунд{1}",
|
"ru": "{0} секунд{1}",
|
||||||
"xloc": [
|
"xloc": [
|
||||||
"player.handlebars->3->3"
|
"player.handlebars->3->3"
|
||||||
@ -21883,4 +21883,4 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -197,7 +197,7 @@
|
|||||||
|
|
||||||
function processFirstBlock(type, flags, time, data) {
|
function processFirstBlock(type, flags, time, data) {
|
||||||
recFileProtocol = 0;
|
recFileProtocol = 0;
|
||||||
if ((type != 1) || (flags != 0)) { cleanup(); return; }
|
if ((type != 1) || (flags > 2)) { cleanup(); return; }
|
||||||
try { recFileMetadata = JSON.parse(data) } catch (ex) { cleanup(); return; }
|
try { recFileMetadata = JSON.parse(data) } catch (ex) { cleanup(); return; }
|
||||||
if ((recFileMetadata == null) || (recFileMetadata.magic != 'MeshCentralRelaySession') || (recFileMetadata.ver != 1)) { cleanup(); return; }
|
if ((recFileMetadata == null) || (recFileMetadata.magic != 'MeshCentralRelaySession') || (recFileMetadata.ver != 1)) { cleanup(); return; }
|
||||||
if (recFileExtras) { for (var i in recFileExtras) { recFileMetadata[i] = recFileExtras[i]; } }
|
if (recFileExtras) { for (var i in recFileExtras) { recFileMetadata[i] = recFileExtras[i]; } }
|
||||||
@ -428,7 +428,7 @@
|
|||||||
recFile = files[0];
|
recFile = files[0];
|
||||||
recFilePtr = 0;
|
recFilePtr = 0;
|
||||||
readNextBlock(processFirstBlock);
|
readNextBlock(processFirstBlock);
|
||||||
readLastBlock(function (type, flags, time) {
|
readLastBlock(function (type, flags, time, extras) {
|
||||||
if (type == 3) {
|
if (type == 3) {
|
||||||
// File is ok
|
// File is ok
|
||||||
recFileEndTime = time;
|
recFileEndTime = time;
|
||||||
|
Loading…
Reference in New Issue
Block a user