Removed depricated new Buffer() usage.
Ylian Saint-Hilaire committed
Aug 6, 2020 at 13:23 UTC
98f2950c002a55a8b564e42f96fa45b9bac4b271
8 files changed
+71
-71
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/meshcmd.js
+1
-1
@@ -2364,7 +2364,7 @@ function pushToStorage(name, linkname, data, func, ptr) {
2364
});
2365
var header = (ptr > 0) ? '<metadata></metadata>' : '<metadata><headers><h>Content-Encoding:gzip</h><h>Content-Type:text/html</h></headers>' + ((linkname != null) ? ('<link>' + linkname + '</link>') : '') + '</metadata>';
2366
var blocklen = ((data.length - ptr) > (7000 - header.length)) ? (7000 - header.length) : (data.length - ptr);
2367
- req.write(Buffer.concat([new Buffer(header), data.slice(ptr, ptr + blocklen)]));
2367
+ req.write(Buffer.concat([Buffer.from(header), data.slice(ptr, ptr + blocklen)]));
2368
ptr += blocklen;
2369
req.end();
2370
}
agents/meshcore.js
+11
-11
@@ -1270,13 +1270,13 @@ function createMeshCore(agent) {
1270
if (typeof data == 'object') {
1271
// Save the data to file being uploaded.
1272
if (this.httprequest.uploadFile) {
1273
- try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { sendConsoleText('FileSave ERROR'); this.write(new Buffer(JSON.stringify({ action: 'uploaderror' }))); return; } // Write to the file, if there is a problem, error out.
1274
- this.write(new Buffer(JSON.stringify({ action: 'uploadack', reqid: this.httprequest.uploadFileid }))); // Ask for more data.
1273
+ try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { sendConsoleText('FileSave ERROR'); this.write(Buffer.from(JSON.stringify({ action: 'uploaderror' }))); return; } // Write to the file, if there is a problem, error out.
1274
+ this.write(Buffer.from(JSON.stringify({ action: 'uploadack', reqid: this.httprequest.uploadFileid }))); // Ask for more data.
1275
}
1276
} else if (typeof data == 'string') {
1277
// Close the file and confirm. We need to make this added round trip since websocket deflate compression can cause the last message before a websocket close to not be received.
1278
if (this.httprequest.uploadFile) { fs.closeSync(this.httprequest.uploadFile); delete this.httprequest.uploadFile; }
1279
- this.write(new Buffer(JSON.stringify({ action: 'uploaddone', reqid: this.httprequest.uploadFileid }))); // Indicate that we closed the file.
1279
+ this.write(Buffer.from(JSON.stringify({ action: 'uploaddone', reqid: this.httprequest.uploadFileid }))); // Indicate that we closed the file.
1280
this.end();
1281
}
1282
return;
@@ -1284,7 +1284,7 @@ function createMeshCore(agent) {
1284
/*
1285
// If this is a download, send more of the file
1286
if (this.httprequest.downloadFile) {
1287
- var buf = new Buffer(4096);
1287
+ var buf = Buffer.alloc(4096);
1288
var len = fs.readSync(this.httprequest.downloadFile, buf, 0, 4096, null);
1289
this.httprequest.downloadFilePtr += len;
1290
if (len > 0) { this.write(buf.slice(0, len)); } else { fs.closeSync(this.httprequest.downloadFile); this.httprequest.downloadFile = undefined; this.end(); }
@@ -1939,7 +1939,7 @@ function createMeshCore(agent) {
1939
} else if (this.httprequest.protocol == 2) {
1940
// Send data into remote desktop
1941
if (this.httprequest.desktop.state == 0) {
1942
- this.write(new Buffer(String.fromCharCode(0x11, 0xFE, 0x00, 0x00, 0x4D, 0x45, 0x53, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02)));
1942
+ this.write(Buffer.from(String.fromCharCode(0x11, 0xFE, 0x00, 0x00, 0x4D, 0x45, 0x53, 0x48, 0x00, 0x00, 0x00, 0x00, 0x02)));
1943
this.httprequest.desktop.state = 1;
1944
} else {
1945
this.httprequest.desktop.write(data);
@@ -1970,7 +1970,7 @@ function createMeshCore(agent) {
1970
// Send the folder content to the browser
1971
var response = getDirectoryInfo(cmd.path);
1972
if (cmd.reqid != undefined) { response.reqid = cmd.reqid; }
1973
- this.write(new Buffer(JSON.stringify(response)));
1973
+ this.write(Buffer.from(JSON.stringify(response)));
1974
1975
/*
1976
// Start the directory watcher
@@ -2044,7 +2044,7 @@ function createMeshCore(agent) {
2044
// Send the next download block(s)
2045
while (sendNextBlock > 0) {
2046
sendNextBlock--;
2047
- var buf = new Buffer(16384);
2047
+ var buf = Buffer.alloc(16384);
2048
var len = fs.readSync(this.filedownload.f, buf, 4, 16380, null);
2049
this.filedownload.ptr += len;
2050
if (len < 16380) { buf.writeInt32BE(0x01000001, 0); fs.closeSync(this.filedownload.f); delete this.filedownload; sendNextBlock = 0; } else { buf.writeInt32BE(0x01000000, 0); }
@@ -2058,10 +2058,10 @@ function createMeshCore(agent) {
2058
if (cmd.path == undefined) break;
2059
var filepath = cmd.name ? obj.path.join(cmd.path, cmd.name) : cmd.path;
2060
//console.log('Download: ' + filepath);
2061
- try { this.httprequest.downloadFile = fs.openSync(filepath, 'rbN'); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'downloaderror', reqid: cmd.reqid }))); break; }
2061
+ try { this.httprequest.downloadFile = fs.openSync(filepath, 'rbN'); } catch (e) { this.write(Buffer.from(JSON.stringify({ action: 'downloaderror', reqid: cmd.reqid }))); break; }
2062
this.httprequest.downloadFileId = cmd.reqid;
2063
this.httprequest.downloadFilePtr = 0;
2064
- if (this.httprequest.downloadFile) { this.write(new Buffer(JSON.stringify({ action: 'downloadstart', reqid: this.httprequest.downloadFileId }))); }
2064
+ if (this.httprequest.downloadFile) { this.write(Buffer.from(JSON.stringify({ action: 'downloadstart', reqid: this.httprequest.downloadFileId }))); }
2065
break;
2066
}
2067
case 'download2': {
@@ -2080,9 +2080,9 @@ function createMeshCore(agent) {
2080
if (cmd.path == undefined) break;
2081
var filepath = cmd.name ? obj.path.join(cmd.path, cmd.name) : cmd.path;
2082
MeshServerLog('Upload: \"' + filepath + '\"', this.httprequest);
2083
- try { this.httprequest.uploadFile = fs.openSync(filepath, 'wbN'); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'uploaderror', reqid: cmd.reqid }))); break; }
2083
+ try { this.httprequest.uploadFile = fs.openSync(filepath, 'wbN'); } catch (e) { this.write(Buffer.from(JSON.stringify({ action: 'uploaderror', reqid: cmd.reqid }))); break; }
2084
this.httprequest.uploadFileid = cmd.reqid;
2085
- if (this.httprequest.uploadFile) { this.write(new Buffer(JSON.stringify({ action: 'uploadstart', reqid: this.httprequest.uploadFileid }))); }
2085
+ if (this.httprequest.uploadFile) { this.write(Buffer.from(JSON.stringify({ action: 'uploadstart', reqid: this.httprequest.uploadFileid }))); }
2086
break;
2087
}
2088
case 'copy': {
agents/modules_meshcmd/amt-ider.js
+43
-43
@@ -30,32 +30,32 @@ module.exports = function CreateAmtRemoteIder() {
30
obj.debug = false;
31
32
// Mode Sense
33
- var IDE_ModeSence_LS120Disk_Page_Array = new Buffer([0x00, 0x26, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]);
34
- var IDE_ModeSence_3F_LS120_Array = new Buffer([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]);
35
- var IDE_ModeSence_FloppyDisk_Page_Array = new Buffer([0x00, 0x26, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x04, 0xB0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]);
36
- var IDE_ModeSence_3F_Floppy_Array = new Buffer([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1e, 0x04, 0xb0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]);
37
- var IDE_ModeSence_CD_1A_Array = new Buffer([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
38
- //var IDE_ModeSence_CD_1B_Array = new Buffer([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
39
- var IDE_ModeSence_CD_1D_Array = new Buffer([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
40
- var IDE_ModeSence_CD_2A_Array = new Buffer([0x00, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
41
- //var IDE_ModeSence_CD_01_Array = new Buffer([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00]);
42
- var IDE_ModeSence_3F_CD_Array = new Buffer([0x00, 0x28, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
33
+ var IDE_ModeSence_LS120Disk_Page_Array = Buffer.from([0x00, 0x26, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]);
34
+ var IDE_ModeSence_3F_LS120_Array = Buffer.from([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x10, 0xA9, 0x08, 0x20, 0x02, 0x00, 0x03, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]);
35
+ var IDE_ModeSence_FloppyDisk_Page_Array = Buffer.from([0x00, 0x26, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x1E, 0x04, 0xB0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD0, 0x00, 0x00]);
36
+ var IDE_ModeSence_3F_Floppy_Array = Buffer.from([0x00, 0x5c, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x16, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x05, 0x1e, 0x04, 0xb0, 0x02, 0x12, 0x02, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xd0, 0x00, 0x00, 0x08, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x11, 0x24, 0x31]);
37
+ var IDE_ModeSence_CD_1A_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
38
+ //var IDE_ModeSence_CD_1B_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
39
+ var IDE_ModeSence_CD_1D_Array = Buffer.from([0x00, 0x12, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
40
+ var IDE_ModeSence_CD_2A_Array = Buffer.from([0x00, 0x20, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
41
+ //var IDE_ModeSence_CD_01_Array = Buffer.from([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00]);
42
+ var IDE_ModeSence_3F_CD_Array = Buffer.from([0x00, 0x28, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
43
44
// 0x46 constant data
45
- var IDE_CD_ConfigArrayHeader = new Buffer([0x00, 0x00,0x00, 0x28, 0x00, 0x00, 0x00, 0x08]);
46
- var IDE_CD_ConfigArrayProfileList = new Buffer([0x00, 0x00, 0x03, 0x04, 0x00, 0x08, 0x01, 0x00]);
47
- var IDE_CD_ConfigArrayCore = new Buffer([0x00, 0x01, 0x03, 0x04, 0x00, 0x00, 0x00, 0x02]);
48
- var IDE_CD_Morphing = new Buffer([0x00, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00]);
49
- var IDE_CD_ConfigArrayRemovable = new Buffer([0x00, 0x03, 0x03, 0x04, 0x29, 0x00, 0x00, 0x02]);
50
- var IDE_CD_ConfigArrayRandom = new Buffer([0x00, 0x10, 0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00]);
51
- var IDE_CD_Read = new Buffer([0x00, 0x1E, 0x03, 0x00]);
52
- var IDE_CD_PowerManagement = new Buffer([0x01, 0x00, 0x03, 0x00]);
53
- var IDE_CD_Timeout = new Buffer([0x01, 0x05, 0x03, 0x00]);
45
+ var IDE_CD_ConfigArrayHeader = Buffer.from([0x00, 0x00,0x00, 0x28, 0x00, 0x00, 0x00, 0x08]);
46
+ var IDE_CD_ConfigArrayProfileList = Buffer.from([0x00, 0x00, 0x03, 0x04, 0x00, 0x08, 0x01, 0x00]);
47
+ var IDE_CD_ConfigArrayCore = Buffer.from([0x00, 0x01, 0x03, 0x04, 0x00, 0x00, 0x00, 0x02]);
48
+ var IDE_CD_Morphing = Buffer.from([0x00, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00]);
49
+ var IDE_CD_ConfigArrayRemovable = Buffer.from([0x00, 0x03, 0x03, 0x04, 0x29, 0x00, 0x00, 0x02]);
50
+ var IDE_CD_ConfigArrayRandom = Buffer.from([0x00, 0x10, 0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00]);
51
+ var IDE_CD_Read = Buffer.from([0x00, 0x1E, 0x03, 0x00]);
52
+ var IDE_CD_PowerManagement = Buffer.from([0x01, 0x00, 0x03, 0x00]);
53
+ var IDE_CD_Timeout = Buffer.from([0x01, 0x05, 0x03, 0x00]);
54
55
// 0x01 constant data
56
- var IDE_ModeSence_FloppyError_Recovery_Array = new Buffer([0x00, 0x12, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]);
57
- var IDE_ModeSence_Ls120Error_Recovery_Array = new Buffer([0x00, 0x12, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]);
58
- var IDE_ModeSence_CDError_Recovery_Array = new Buffer([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00]);
56
+ var IDE_ModeSence_FloppyError_Recovery_Array = Buffer.from([0x00, 0x12, 0x24, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]);
57
+ var IDE_ModeSence_Ls120Error_Recovery_Array = Buffer.from([0x00, 0x12, 0x31, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00]);
58
+ var IDE_ModeSence_CDError_Recovery_Array = Buffer.from([0x00, 0x0E, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00]);
59
60
61
// Private method, called by parent when it change state
@@ -114,7 +114,7 @@ module.exports = function CreateAmtRemoteIder() {
114
115
// Private method
116
obj.SendCommand = function (cmdid, data, completed, dma) {
117
- if (data == null) { data = new Buffer(0); }
117
+ if (data == null) { data = Buffer.alloc(0); }
118
var attributes = ((cmdid > 50) && (completed == true)) ? 2 : 0;
119
if (dma) { attributes += 1; }
120
var x = Buffer.concat([Buffer([cmdid, 0, 0, attributes]), IntToStrX(obj.outSequence++), data]);
@@ -125,28 +125,28 @@ module.exports = function CreateAmtRemoteIder() {
125
126
// CommandEndResponse (SCSI_SENSE)
127
obj.SendCommandEndResponse = function (error, sense, device, asc, asq) {
128
- if (error) { obj.SendCommand(0x51, new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc5, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0]), true); }
129
- else { obj.SendCommand(0x51, new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87, (sense << 4), 3, 0, 0, 0, device, 0x51, sense, asc, asq]), true); }
128
+ if (error) { obj.SendCommand(0x51, Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc5, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0]), true); }
129
+ else { obj.SendCommand(0x51, Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87, (sense << 4), 3, 0, 0, 0, device, 0x51, sense, asc, asq]), true); }
130
}
131
132
// DataToHost (SCSI_READ)
133
obj.SendDataToHost = function (device, completed, data, dma) {
134
var dmalen = (dma) ? 0 : data.length;
135
if (completed == true) {
136
- obj.SendCommand(0x54, Buffer.concat([new Buffer([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0x85, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0, 0, 0, 0]), data ]), completed, dma);
136
+ obj.SendCommand(0x54, Buffer.concat([Buffer.from([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0x85, 0, 3, 0, 0, 0, device, 0x50, 0, 0, 0, 0, 0, 0]), data ]), completed, dma);
137
} else {
138
- obj.SendCommand(0x54, Buffer.concat([new Buffer([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), data]), completed, dma);
138
+ obj.SendCommand(0x54, Buffer.concat([Buffer.from([0, (data.length & 0xff), (data.length >> 8), 0, dma ? 0xb4 : 0xb5, 0, 2, 0, (dmalen & 0xff), (dmalen >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), data]), completed, dma);
139
}
140
}
141
142
// GetDataFromHost (SCSI_CHUNK)
143
obj.SendGetDataFromHost = function (device, chunksize) {
144
- obj.SendCommand(0x52, new Buffer([0, (chunksize & 0xff), (chunksize >> 8), 0, 0xb5, 0, 0, 0, (chunksize & 0xff), (chunksize >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), false);
144
+ obj.SendCommand(0x52, Buffer.from([0, (chunksize & 0xff), (chunksize >> 8), 0, 0xb5, 0, 0, 0, (chunksize & 0xff), (chunksize >> 8), device, 0x58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), false);
145
}
146
147
// DisableEnableFeatures (STATUS_DATA)
148
// If type is REGS_TOGGLE (3), 4 bytes of data must be provided.
149
- obj.SendDisableEnableFeatures = function (type, data) { if (data == null) { data = ''; } obj.SendCommand(0x48, Buffer.concat([new Buffer([type]), data])); }
149
+ obj.SendDisableEnableFeatures = function (type, data) { if (data == null) { data = ''; } obj.SendCommand(0x48, Buffer.concat([Buffer.from([type]), data])); }
150
151
// Private method
152
obj.ProcessDataEx = function () {
@@ -260,7 +260,7 @@ module.exports = function CreateAmtRemoteIder() {
260
var len = ReadShortX(obj.acc, 9);
261
if (obj.acc.length < (14 + len)) return 0;
262
if (obj.debug) console.log('SCSI_WRITE, len = ' + (14 + len));
263
- obj.SendCommand(0x51, new Buffer([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x70, 0x03, 0x00, 0x00, 0x00, 0xa0, 0x51, 0x07, 0x27, 0x00]), true);
263
+ obj.SendCommand(0x51, Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x70, 0x03, 0x00, 0x00, 0x00, 0xa0, 0x51, 0x07, 0x27, 0x00]), true);
264
return 14 + len;
265
default:
266
if (obj.debug) console.log('Unknown IDER command', obj.acc[0]);
@@ -333,7 +333,7 @@ module.exports = function CreateAmtRemoteIder() {
333
if (obj.debug) console.log("SCSI Internal error 6", dev);
334
return -1;
335
}
336
- obj.SendDataToHost(dev, true, new Buffer([0, a, b, 0]), featureRegister & 1);
336
+ obj.SendDataToHost(dev, true, Buffer.from([0, a, b, 0]), featureRegister & 1);
337
return;
338
}
339
obj.SendCommandEndResponse(1, 0x05, dev, 0x24, 0x00);
@@ -370,7 +370,7 @@ module.exports = function CreateAmtRemoteIder() {
370
return -1;
371
}
372
373
- obj.SendDataToHost(dev, true, Buffer.concat([ IntToStr(8), new Buffer([0x00, 0x00, 0x0b, 0x40, 0x02, 0x00, 0x02, 0x00]) ]), featureRegister & 1);
373
+ obj.SendDataToHost(dev, true, Buffer.concat([IntToStr(8), Buffer.from([0x00, 0x00, 0x0b, 0x40, 0x02, 0x00, 0x02, 0x00]) ]), featureRegister & 1);
374
break;
375
case 0x25: // READ_CAPACITY
376
if (obj.debug) console.log("SCSI: READ_CAPACITY", dev);
@@ -393,7 +393,7 @@ module.exports = function CreateAmtRemoteIder() {
393
}
394
//if (dev == 0xA0) { dev = 0x00; } else { dev = 0x10; } // Weird but seems to work.
395
if (obj.debug) console.log("SCSI: READ_CAPACITY2", dev, deviceFlags);
396
- obj.SendDataToHost(deviceFlags, true, Buffer.concat([IntToStr(len), new Buffer([0, 0, ((dev == 0xB0) ? 0x08 : 0x02), 0])]), featureRegister & 1);
396
+ obj.SendDataToHost(deviceFlags, true, Buffer.concat([IntToStr(len), Buffer.from([0, 0, ((dev == 0xB0) ? 0x08 : 0x02), 0])]), featureRegister & 1);
397
break;
398
case 0x28: // READ_10
399
lba = ReadInt(cdb, 2);
@@ -427,12 +427,12 @@ module.exports = function CreateAmtRemoteIder() {
427
return -1;
428
}
429
430
- if (format == 1) { obj.SendDataToHost(dev, true, new Buffer([0x00, 0x0a, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1); }
430
+ if (format == 1) { obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x0a, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1); }
431
else if (format == 0) {
432
if (msf) {
433
- obj.SendDataToHost(dev, true, new Buffer([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x34, 0x13]), featureRegister & 1);
433
+ obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x34, 0x13]), featureRegister & 1);
434
} else {
435
- obj.SendDataToHost(dev, true, new Buffer([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1);
435
+ obj.SendDataToHost(dev, true, Buffer.from([0x00, 0x12, 0x01, 0x01, 0x00, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00]), featureRegister & 1);
436
}
437
}
438
break;
@@ -482,10 +482,10 @@ module.exports = function CreateAmtRemoteIder() {
482
var present = 0x00;
483
if ((dev == 0xA0) && (obj.floppy != null)) { present = 0x02; }
484
else if ((dev == 0xB0) && (obj.cdrom != null)) { present = 0x02; }
485
- obj.SendDataToHost(dev, true, new Buffer([0x00, present, 0x80, 0x00]), featureRegister & 1); // This is the original version, 4 bytes long
485
+ obj.SendDataToHost(dev, true, Buffer.from([0x00, present, 0x80, 0x00]), featureRegister & 1); // This is the original version, 4 bytes long
486
break;
487
case 0x4c:
488
- obj.SendCommand(0x51, Buffer.concat([ IntToStrX(0), IntToStrX(0), IntToStrX(0), new Buffer([0x87, 0x50, 0x03, 0x00, 0x00, 0x00, 0xb0, 0x51, 0x05, 0x20, 0x00]) ]), true);
488
+ obj.SendCommand(0x51, Buffer.concat([IntToStrX(0), IntToStrX(0), IntToStrX(0), Buffer.from([0x87, 0x50, 0x03, 0x00, 0x00, 0x00, 0xb0, 0x51, 0x05, 0x20, 0x00]) ]), true);
489
break;
490
case 0x51: // READ_DISC_INFO
491
if (obj.debug) console.log("SCSI READ_DISC_INFO", dev);
@@ -575,7 +575,7 @@ module.exports = function CreateAmtRemoteIder() {
575
576
//console.log('Read from ' + lba + ' to ' + (lba + len) + ', total of ' + len);
577
578
- var result = new Buffer(len);
578
+ var result = Buffer.alloc(len);
579
fs.readSync(g_media.file, result, 0, len, lba);
580
obj.SendDataToHost(g_dev, (g_len == 0), result, featureRegister & 1);
581
if ((g_len > 0) && (g_reset == false)) {
@@ -590,10 +590,10 @@ module.exports = function CreateAmtRemoteIder() {
590
return obj;
591
}
592
593
-function ShortToStr(v) { return new Buffer([(v >> 8) & 0xFF, v & 0xFF]); }
594
-function ShortToStrX(v) { return new Buffer([v & 0xFF, (v >> 8) & 0xFF]); }
595
-function IntToStr(v) { return new Buffer([(v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF]); }
596
-function IntToStrX(v) { return new Buffer([v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF]); }
593
+function ShortToStr(v) { return Buffer.from([(v >> 8) & 0xFF, v & 0xFF]); }
594
+function ShortToStrX(v) { return Buffer.from([v & 0xFF, (v >> 8) & 0xFF]); }
595
+function IntToStr(v) { return Buffer.from([(v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF]); }
596
+function IntToStrX(v) { return Buffer.from([v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF]); }
597
function ReadShort(v, p) { return (v[p] << 8) + v[p + 1]; }
598
function ReadShortX(v, p) { return (v[p + 1] << 8) + v[p]; }
599
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.
agents/modules_meshcmd/amt-redir-duk.js
+9
-9
@@ -173,8 +173,8 @@ module.exports = function CreateAmtRedirect(module) {
173
var digest = hex_md5(hex_md5(obj.user + ":" + realm + ":" + obj.pass) + ":" + nonce + ":" + extra + hex_md5("POST:" + obj.authuri));
174
var totallen = obj.user.length + realm.length + nonce.length + obj.authuri.length + cnonce.length + snc.length + digest.length + 7;
175
if (authType == 4) totallen += (qop.length + 1);
176
- var buf = Buffer.concat([new Buffer([0x13, 0x00, 0x00, 0x00, authType]), new Buffer([totallen & 0xFF, (totallen >> 8) & 0xFF, 0x00, 0x00]), new Buffer([obj.user.length]), new Buffer(obj.user), new Buffer([realm.length]), new Buffer(realm), new Buffer([nonce.length]), new Buffer(nonce), new Buffer([obj.authuri.length]), new Buffer(obj.authuri), new Buffer([cnonce.length]), new Buffer(cnonce), new Buffer([snc.length]), new Buffer(snc), new Buffer([digest.length]), new Buffer(digest)]);
177
- if (authType == 4) buf = Buffer.concat([ buf, new Buffer([qop.length]), new Buffer(qop) ]);
176
+ var buf = Buffer.concat([Buffer.from([0x13, 0x00, 0x00, 0x00, authType]), new Buffer([totallen & 0xFF, (totallen >> 8) & 0xFF, 0x00, 0x00]), new Buffer([obj.user.length]), new Buffer(obj.user), new Buffer([realm.length]), new Buffer(realm), new Buffer([nonce.length]), new Buffer(nonce), new Buffer([obj.authuri.length]), new Buffer(obj.authuri), new Buffer([cnonce.length]), new Buffer(cnonce), new Buffer([snc.length]), new Buffer(snc), new Buffer([digest.length]), new Buffer(digest)]);
177
+ if (authType == 4) buf = Buffer.concat([buf, Buffer.from([qop.length]), new Buffer(qop) ]);
178
obj.xxSend(buf);
179
}
180
else if (status == 0) { // Success
@@ -192,7 +192,7 @@ module.exports = function CreateAmtRedirect(module) {
192
}
193
if (obj.protocol == 2) {
194
// Remote Desktop: Send traffic directly...
195
- obj.xxSend(new Buffer([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]));
195
+ obj.xxSend(Buffer.from([0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]));
196
}
197
if (obj.protocol == 3) {
198
// Remote IDER: Send traffic directly...
@@ -244,8 +244,8 @@ module.exports = function CreateAmtRedirect(module) {
244
245
obj.xxSend = function (x) {
246
if (urlvars && urlvars['redirtrace']) { console.log("REDIR-SEND(" + x.length + "): " + rstr2hex(x)); }
247
- //obj.Debug("Send(" + x.length + "): " + new Buffer(x, "binary").toString('hex'));
248
- if (typeof x == 'string') { obj.socket.write(new Buffer(x, "binary")); } else { obj.socket.write(x); }
247
+ //obj.Debug("Send(" + x.length + "): " + Buffer.from(x, "binary").toString('hex'));
248
+ if (typeof x == 'string') { obj.socket.write(Buffer.from(x, "binary")); } else { obj.socket.write(x); }
249
}
250
251
obj.Send = function (x) {
@@ -262,7 +262,7 @@ module.exports = function CreateAmtRedirect(module) {
262
obj.xxRandomValueHex = function (len) {
263
var t = [], l = Math.floor(len / 2);
264
for (var i = 0; i < l; i++) { t.push(obj.tls.generateRandomInteger("0", "255")); }
265
- return new Buffer(t).toString('hex');
265
+ return Buffer.from(t).toString('hex');
266
}
267
268
obj.xxOnSocketClosed = function () {
@@ -289,9 +289,9 @@ module.exports = function CreateAmtRedirect(module) {
289
if (obj.amtkeepalivetimer != null) { clearInterval(obj.amtkeepalivetimer); obj.amtkeepalivetimer = null; }
290
}
291
292
- obj.RedirectStartSol = new Buffer([0x10, 0x00, 0x00, 0x00, 0x53, 0x4F, 0x4C, 0x20]);
293
- obj.RedirectStartKvm = new Buffer([0x10, 0x01, 0x00, 0x00, 0x4b, 0x56, 0x4d, 0x52]);
294
- obj.RedirectStartIder = new Buffer([0x10, 0x00, 0x00, 0x00, 0x49, 0x44, 0x45, 0x52]);
292
+ obj.RedirectStartSol = Buffer.from([0x10, 0x00, 0x00, 0x00, 0x53, 0x4F, 0x4C, 0x20]);
293
+ obj.RedirectStartKvm = Buffer.from([0x10, 0x01, 0x00, 0x00, 0x4b, 0x56, 0x4d, 0x52]);
294
+ obj.RedirectStartIder = Buffer.from([0x10, 0x00, 0x00, 0x00, 0x49, 0x44, 0x45, 0x52]);
295
296
return obj;
297
}
agents/recoverycore.js
+5
-5
@@ -233,8 +233,8 @@ require('MeshAgent').AddCommandHandler(function (data) {
233
s.on('data', function (data) {
234
// If this is upload data, save it to file
235
if (this.httprequest.uploadFile) {
236
- try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'uploaderror' }))); return; } // Write to the file, if there is a problem, error out.
237
- this.write(new Buffer(JSON.stringify({ action: 'uploadack', reqid: this.httprequest.uploadFileid }))); // Ask for more data
236
+ try { fs.writeSync(this.httprequest.uploadFile, data); } catch (e) { this.write(Buffer.from(JSON.stringify({ action: 'uploaderror' }))); return; } // Write to the file, if there is a problem, error out.
237
+ this.write(Buffer.from(JSON.stringify({ action: 'uploadack', reqid: this.httprequest.uploadFileid }))); // Ask for more data
238
return;
239
}
240
@@ -334,7 +334,7 @@ require('MeshAgent').AddCommandHandler(function (data) {
334
// Send the folder content to the browser
335
var response = getDirectoryInfo(cmd.path);
336
if (cmd.reqid != undefined) { response.reqid = cmd.reqid; }
337
- this.write(new Buffer(JSON.stringify(response)));
337
+ this.write(Buffer.from(JSON.stringify(response)));
338
break;
339
case 'mkdir': {
340
// Create a new empty folder
@@ -360,9 +360,9 @@ require('MeshAgent').AddCommandHandler(function (data) {
360
if (this.httprequest.uploadFile != undefined) { fs.closeSync(this.httprequest.uploadFile); this.httprequest.uploadFile = undefined; }
361
if (cmd.path == undefined) break;
362
var filepath = cmd.name ? path.join(cmd.path, cmd.name) : cmd.path;
363
- try { this.httprequest.uploadFile = fs.openSync(filepath, 'wbN'); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'uploaderror', reqid: cmd.reqid }))); break; }
363
+ try { this.httprequest.uploadFile = fs.openSync(filepath, 'wbN'); } catch (e) { this.write(Buffer.from(JSON.stringify({ action: 'uploaderror', reqid: cmd.reqid }))); break; }
364
this.httprequest.uploadFileid = cmd.reqid;
365
- if (this.httprequest.uploadFile) { this.write(new Buffer(JSON.stringify({ action: 'uploadstart', reqid: this.httprequest.uploadFileid }))); }
365
+ if (this.httprequest.uploadFile) { this.write(Buffer.from(JSON.stringify({ action: 'uploadstart', reqid: this.httprequest.uploadFileid }))); }
366
break;
367
}
368
case 'copy': {
amt/amt-redir-mesh.js
+2
-2
@@ -456,10 +456,10 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
456
}
457
458
obj.xxSend = function (x) {
459
- if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + new Buffer(x, "binary").toString('hex'), typeof x); }
459
+ if (obj.redirTrace) { console.log("REDIR-SEND(" + x.length + "): " + Buffer.from(x, "binary").toString('hex'), typeof x); }
460
//obj.Debug("Send(" + x.length + "): " + webserver.common.rstr2hex(x));
461
//obj.forwardclient.write(x); // FIXES CIRA
462
- obj.forwardclient.write(new Buffer(x, "binary"));
462
+ obj.forwardclient.write(Buffer.from(x, "binary"));
463
}
464
465
obj.Send = function (x) {