Merge branch 'dev' into proxy-logiv-dev-v4

This commit is contained in:
Stephen McLaughlin
2024-05-30 11:44:53 +01:00
committed by GitHub
107 changed files with 5096 additions and 2510 deletions

View File

@@ -25,11 +25,9 @@ var api = require("@node-red/editor-api");
var server = null;
var apiEnabled = false;
const NODE_MAJOR_VERSION = process.versions.node.split('.')[0];
if (NODE_MAJOR_VERSION >= 16) {
const dns = require('dns');
dns.setDefaultResultOrder('ipv4first');
}
// Ensure ipv4 results are returned first: https://github.com/node-red/node-red/issues/4010
const dns = require('dns');
dns.setDefaultResultOrder('ipv4first');
function checkVersion(userSettings) {
var semver = require('semver');

View File

@@ -1,6 +1,6 @@
{
"name": "node-red",
"version": "4.0.0-beta.1",
"version": "4.0.0-beta.3-1",
"description": "Low-code programming for event-driven applications",
"homepage": "https://nodered.org",
"license": "Apache-2.0",
@@ -31,10 +31,10 @@
"flow"
],
"dependencies": {
"@node-red/editor-api": "4.0.0-beta.1",
"@node-red/runtime": "4.0.0-beta.1",
"@node-red/util": "4.0.0-beta.1",
"@node-red/nodes": "4.0.0-beta.1",
"@node-red/editor-api": "4.0.0-beta.3-1",
"@node-red/runtime": "4.0.0-beta.3-1",
"@node-red/util": "4.0.0-beta.3-1",
"@node-red/nodes": "4.0.0-beta.3-1",
"basic-auth": "2.0.1",
"bcryptjs": "2.4.3",
"express": "4.19.2",
@@ -47,6 +47,6 @@
"bcrypt": "5.1.0"
},
"engines": {
"node": ">=18"
"node": ">=18.5"
}
}

View File

@@ -42,6 +42,7 @@ try { bcrypt = require('bcrypt'); }
catch(e) { bcrypt = require('bcryptjs'); }
var nopt = require("nopt");
var path = require("path");
const os = require("os")
var fs = require("fs-extra");
var RED = require("./lib/red.js");
@@ -59,6 +60,7 @@ var knownOpts = {
"userDir": [path],
"verbose": Boolean,
"safe": Boolean,
"version": Boolean,
"define": [String, Array]
};
var shortHands = {
@@ -92,6 +94,7 @@ if (parsedArgs.help) {
console.log(" -v, --verbose enable verbose output");
console.log(" --safe enable safe mode");
console.log(" -D, --define X=Y overwrite value in settings file");
console.log(" --version show version information");
console.log(" -?, --help show this help");
console.log(" admin <command> run an admin command");
console.log("");
@@ -99,6 +102,13 @@ if (parsedArgs.help) {
process.exit();
}
if (parsedArgs.version) {
console.log("Node-RED v"+RED.version())
console.log("Node.js "+process.version)
console.log(os.type()+" "+os.release()+" "+os.arch()+" "+os.endianness())
process.exit()
}
if (parsedArgs.argv.remain.length > 0) {
flowFile = parsedArgs.argv.remain[0];
}
@@ -240,39 +250,34 @@ httpsPromise.then(function(startupHttps) {
// Max value based on (2^31-1)ms - the max that setInterval can accept
httpsRefreshInterval = 596;
}
// Check whether setSecureContext is available (Node.js 11+)
if (server.setSecureContext) {
// Check whether `http` is a callable function
if (typeof settings.https === "function") {
delayedLogItems.push({type:"info", id:"server.https.refresh-interval", params:{interval:httpsRefreshInterval}});
setInterval(function () {
try {
// Get the result of the function, because createServer doesn't accept functions as input
Promise.resolve(settings.https()).then(function(refreshedHttps) {
if (refreshedHttps) {
// The key/cert needs to be updated in the NodeJs http(s) server, when no key/cert is yet available or when the key/cert has changed.
// Note that the refreshed key/cert can be supplied as a string or a buffer.
var updateKey = (server.key == undefined || (Buffer.isBuffer(server.key) && !server.key.equals(refreshedHttps.key)) || (typeof server.key == "string" && server.key != refreshedHttps.key));
var updateCert = (server.cert == undefined || (Buffer.isBuffer(server.cert) && !server.cert.equals(refreshedHttps.cert)) || (typeof server.cert == "string" && server.cert != refreshedHttps.cert));
// Check whether `http` is a callable function
if (typeof settings.https === "function") {
delayedLogItems.push({type:"info", id:"server.https.refresh-interval", params:{interval:httpsRefreshInterval}});
setInterval(function () {
try {
// Get the result of the function, because createServer doesn't accept functions as input
Promise.resolve(settings.https()).then(function(refreshedHttps) {
if (refreshedHttps) {
// The key/cert needs to be updated in the NodeJs http(s) server, when no key/cert is yet available or when the key/cert has changed.
// Note that the refreshed key/cert can be supplied as a string or a buffer.
var updateKey = (server.key == undefined || (Buffer.isBuffer(server.key) && !server.key.equals(refreshedHttps.key)) || (typeof server.key == "string" && server.key != refreshedHttps.key));
var updateCert = (server.cert == undefined || (Buffer.isBuffer(server.cert) && !server.cert.equals(refreshedHttps.cert)) || (typeof server.cert == "string" && server.cert != refreshedHttps.cert));
// Only update the credentials in the server when key or cert has changed
if(updateKey || updateCert) {
server.setSecureContext(refreshedHttps);
RED.log.info(RED.log._("server.https.settings-refreshed"));
}
// Only update the credentials in the server when key or cert has changed
if(updateKey || updateCert) {
server.setSecureContext(refreshedHttps);
RED.log.info(RED.log._("server.https.settings-refreshed"));
}
}).catch(function(err) {
RED.log.error(RED.log._("server.https.refresh-failed",{message:err}));
});
} catch(err) {
}
}).catch(function(err) {
RED.log.error(RED.log._("server.https.refresh-failed",{message:err}));
}
}, httpsRefreshInterval*60*60*1000);
} else {
delayedLogItems.push({type:"warn", id:"server.https.function-required"});
}
});
} catch(err) {
RED.log.error(RED.log._("server.https.refresh-failed",{message:err}));
}
}, httpsRefreshInterval*60*60*1000);
} else {
delayedLogItems.push({type:"warn", id:"server.https.nodejs-version"});
delayedLogItems.push({type:"warn", id:"server.https.function-required"});
}
}
} else {

View File

@@ -133,6 +133,7 @@ module.exports = {
* - httpServerOptions
* - httpAdminRoot
* - httpAdminMiddleware
* - httpAdminCookieOptions
* - httpNodeRoot
* - httpNodeCors
* - httpNodeMiddleware
@@ -178,6 +179,11 @@ module.exports = {
// next();
// },
/** The following property can be used to set addition options on the session
* cookie used as part of adminAuth authentication system
* Available options are documented here: https://www.npmjs.com/package/express-session#cookie
*/
// httpAdminCookieOptions: { },
/** Some nodes, such as HTTP In, can be used to listen for incoming http requests.
* By default, these are served relative to '/'. The following property
@@ -445,6 +451,10 @@ module.exports = {
}
},
multiplayer: {
/** To enable the Multiplayer feature, set this value to true */
enabled: false
},
},
/*******************************************************************************