Skip to content

Commit

Permalink
Merge pull request #4314 from Rotzbua/remove_outdated_node_check
Browse files Browse the repository at this point in the history
fix: remove outdated Node 11+ check
  • Loading branch information
knolleary committed May 14, 2024
2 parents 70167d7 + d706c9c commit d520cde
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"refresh-interval": "Erneuerung der https-Einstellungen erfolgt alle __interval__ Stunden",
"settings-refreshed": "https-Einstellungen wurden erneuert",
"refresh-failed": "Erneuerung der https-Einstellungen fehlgeschlagen: __message__",
"nodejs-version": "httpsRefreshInterval erfordert Node.js 11 oder höher",
"function-required": "httpsRefreshInterval erfordert die https-Eigenschaft in Form einer Funktion"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"refresh-interval": "Refreshing https settings every __interval__ hours",
"settings-refreshed": "Server https settings have been refreshed",
"refresh-failed": "Failed to refresh https settings: __message__",
"nodejs-version": "httpsRefreshInterval requires Node.js 11 or later",
"function-required": "httpsRefreshInterval requires https property to be a function"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"refresh-interval": "Actualizando la configuración HTTPS cada __interval__ horas",
"settings-refreshed": "La configuración HTTPS del servidor se ha actualizado",
"refresh-failed": "No se pudo actualizar la configuración HTTPS: __message__",
"nodejs-version": "httpsRefreshInterval requiere Node.js 11 o superior",
"function-required": "httpsRefreshInterval requiere que la propiedad HTTPS sea una función"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"refresh-interval": "Actualisation des paramètres https toutes les __interval__ heures",
"settings-refreshed": "Les paramètres https du serveur ont été actualisés",
"refresh-failed": "Échec de l'actualisation des paramètres https : __message__",
"nodejs-version": "httpsRefreshInterval nécessite Node.js 11 ou version ultérieure",
"function-required": "httpsRefreshInterval nécessite que la propriété https soit une fonction"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"refresh-interval": "__interval__ 時間毎にhttps設定を更新します",
"settings-refreshed": "サーバのhttps設定が更新されました",
"refresh-failed": "https設定の更新で失敗しました: __message__",
"nodejs-version": "httpsRefreshIntervalにはNode.js 11以降が必要です",
"function-required": "httpsRefreshIntervalでは、httpsプロパティはfunctionである必要があります"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"refresh-interval": "Atualizando as configurações de https a cada __interval__ hora(s)",
"settings-refreshed": "As configurações https do servidor foram atualizadas",
"refresh-failed": "Falha ao atualizar as configurações https: __message__",
"nodejs-version": "httpsRefreshInterval requer Node.js 11 ou posterior",
"function-required": "httpsRefreshInterval requer que a propriedade https seja uma função"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"refresh-interval": "Обновление настроек https каждые __interval__ часов",
"settings-refreshed": "Настройки сервера https обновлены",
"refresh-failed": "Не удалось обновить настройки https: __message__",
"nodejs-version": "httpsRefreshInterval требует Node.js 11 или выше",
"function-required": "httpsRefreshInterval требует, чтобы свойство https было функцией"
}
},
Expand Down
55 changes: 25 additions & 30 deletions packages/node_modules/node-red/red.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,39 +240,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));

// 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"));
}
// 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"));
}
}).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 {
Expand Down

0 comments on commit d520cde

Please sign in to comment.