1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Fix ping node to pass through properties.

This commit is contained in:
Dave Conway-Jones 2022-09-30 10:05:59 +01:00
parent 3dcf739c0d
commit c8975019ad
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 7 additions and 6 deletions

View File

@ -4,7 +4,7 @@ module.exports = function(RED) {
var spawn = require("child_process").spawn;
var plat = require("os").platform();
function doPing(node, host, arrayMode) {
function doPing(node, host, msg, arrayMode) {
const defTimeout = 5000;
var ex, ex6, hostOptions, commandLineOptions;
if (typeof host === "string") {
@ -20,7 +20,8 @@ module.exports = function(RED) {
hostOptions.timeout = hostOptions.timeout < 1000 ? 1000 : hostOptions.timeout;
hostOptions.timeout = hostOptions.timeout > 30000 ? 30000 : hostOptions.timeout;
var timeoutS = Math.round(hostOptions.timeout / 1000); //whole numbers only
var msg = { payload:false, topic:hostOptions.host };
msg.payload = false;
msg.topic = hostOptions.host;
//only include the extra msg object if operating in advance/array mode.
if (arrayMode) {
msg.ping = hostOptions
@ -221,7 +222,7 @@ module.exports = function(RED) {
let pingables = generatePingList(node.host);
for (let index = 0; index < pingables.length; index++) {
const element = pingables[index];
if (element) { doPing(node, element, false); }
if (element) { doPing(node, element, {}, false); }
}
}, node.timer);
}
@ -234,12 +235,12 @@ module.exports = function(RED) {
let pingables = generatePingList(payload)
for (let index = 0; index < pingables.length; index++) {
const element = pingables[index];
if (element) { doPing(node, element, false); }
if (element) { doPing(node, element, msg, false); }
}
} else if (Array.isArray(payload) ) {
for (let index = 0; index < payload.length; index++) {
const element = payload[index];
if (element) { doPing(node, element, true); }
if (element) { doPing(node, element, msg, true); }
}
}
});

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-ping",
"version" : "0.3.1",
"version" : "0.3.2",
"description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.",
"dependencies" : {
},