Fix for Node 11.10 deprecation of require('constants').
Ylian Saint-Hilaire committed
Feb 26, 2019 at 15:49 UTC
50684bb44754e0a5e5d7da3704f9d13dfa2b320a
3 files changed
+4
-4
amtscanner.js
+2
-2
@@ -21,7 +21,6 @@ module.exports.CreateAmtScanner = function (parent) {
21
obj.net = require('net');
22
obj.tls = require('tls');
23
obj.dns = require('dns');
24
- obj.constants = require('constants');
24
obj.dgram = require('dgram');
25
obj.common = require('./common.js');
26
obj.servers = {};
@@ -36,6 +35,7 @@ module.exports.CreateAmtScanner = function (parent) {
35
obj.nextTag = 0;
36
const PeriodicScanTime = 30000; // Interval between scan sweeps
37
const PeriodicScanTimeout = 65000; // After this time, timeout the device.
38
+ const constants = (require('crypto').constants ? require('crypto').constants : require('constants')); // require('constants') is deprecated in Node 11.10, use require('crypto').constants instead.
39
40
// Build a RMCP packet with a given tag field
41
obj.buildRmcpPing = function (tag) {
@@ -371,7 +371,7 @@ module.exports.CreateAmtScanner = function (parent) {
371
} else {
372
// Connect using TLS, we will switch from default TLS to TLS1-only and back if we get a connection error to support older Intel AMT.
373
if (scaninfo.tlsoption == null) { scaninfo.tlsoption = 0; }
374
- client = obj.tls.connect(port, host, scaninfo.tlsoption == 1 ? { secureProtocol: 'TLSv1_method', rejectUnauthorized: false, ciphers: 'RSA+AES:!aNULL:!MD5:!DSS', secureOptions: obj.constants.SSL_OP_NO_SSLv2 | obj.constants.SSL_OP_NO_SSLv3 | obj.constants.SSL_OP_NO_COMPRESSION | obj.constants.SSL_OP_CIPHER_SERVER_PREFERENCE } : { rejectUnauthorized: false, ciphers: 'RSA+AES:!aNULL:!MD5:!DSS', secureOptions: obj.constants.SSL_OP_NO_SSLv2 | obj.constants.SSL_OP_NO_SSLv3 | obj.constants.SSL_OP_NO_COMPRESSION | obj.constants.SSL_OP_CIPHER_SERVER_PREFERENCE }, function () { this.write('GET / HTTP/1.1\r\nhost: ' + host + '\r\n\r\n'); });
374
+ client = obj.tls.connect(port, host, scaninfo.tlsoption == 1 ? { secureProtocol: 'TLSv1_method', rejectUnauthorized: false, ciphers: 'RSA+AES:!aNULL:!MD5:!DSS', secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_COMPRESSION | constants.SSL_OP_CIPHER_SERVER_PREFERENCE } : { rejectUnauthorized: false, ciphers: 'RSA+AES:!aNULL:!MD5:!DSS', secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_COMPRESSION | constants.SSL_OP_CIPHER_SERVER_PREFERENCE }, function () { this.write('GET / HTTP/1.1\r\nhost: ' + host + '\r\n\r\n'); });
375
}
376
client.scaninfo = scaninfo;
377
client.func = func;
mpsserver.js
+1
-1
@@ -23,7 +23,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
23
obj.ciraConnections = {};
24
var tlsSessionStore = {}; // Store TLS session information for quick resume.
25
var tlsSessionStoreCount = 0; // Number of cached TLS session information in store.
26
- const constants = require('constants');
26
+ const constants = (require('crypto').constants ? require('crypto').constants : require('constants')); // require('constants') is deprecated in Node 11.10, use require('crypto').constants instead.
27
const common = require("./common.js");
28
const net = require("net");
29
const tls = require("tls");
webserver.js
+1
-1
@@ -59,7 +59,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
59
obj.meshRelayHandler = require('./meshrelay.js');
60
obj.meshUserHandler = require('./meshuser.js');
61
obj.interceptor = require('./interceptor');
62
- const constants = require('constants');
62
+ const constants = (obj.crypto.constants ? obj.crypto.constants : require('constants')); // require('constants') is deprecated in Node 11.10, use require('crypto').constants instead.
63
64
// Variables
65
obj.parent = parent;