Node-red-node-ping - Add options for IPv4/IPv6 selection

When using node-red-node-ping for communicate to an URL, there should be an option to select which IP version to use (Auto, IPv4 or IPv6). This will be useful to verify connectivity (Of node-red server's and/or destination server) for each protocol. It can be set as Auto by default.

I looked at the node. I could add this feature for Linux, however I'd need help to bring all supported platforms up to date.

relevant code in the node:

if (plat == "linux" || plat == "android") {
            commandLineOptions = ["-n", "-w", timeoutS, "-c", "1"]
        } else if (plat.match(/^win/)) {
            commandLineOptions = ["-n", "1", "-w", hostOptions.timeout]
        } else if (plat == "darwin" || plat == "freebsd") {
            commandLineOptions = ["-n", "-t", timeoutS, "-c", "1"]
        } else {
            node.error("Sorry - your platform - "+plat+" - is not recognised.", msg);
            return; //dont pass go - just return!
        }

By all means create a Pull request - but yes ideally it would ned to work across all platforms (otherwise the UI would then have to allow selection per platform - and moving flows from one platform to another may break etc... - but surely the help pages for ping on each platform can help :slight_smile:

I'll Code it up this weekend and put a pull request. Would you like me to take a stab at
darwin AKA Mac, and Windows? ? It would have to go in the beta branch and let users that have them OS's test it for me.

I can do the linux tests.

Yes. Sounds good.

For windows, CLI modifiers are -4 and -6:

ping www.example.com - Automatic selection of protocol (IPv6 takes preference, I believe)
ping -4 www.example.com - IPv4
ping -6 www.example.com - IPv6

For MacOS, ping man page doesn't list an option to make the choice. I'm asking to people who do use the system to provided the data, if indeed the choice exists

I think you have to use ping6 command for mac

For MacOS. "ping" is used for IPv4, and "ping6" is used for IPv6.

Thanks for the help guys .... keep it coming.
I've started pecking at it as of today.

ping1

  • User interface ( the node's properties ) and locals - I don't think It should have a AUTO option. Just defaults to IPv4 and user can select IPv6. I don't want to make any breaking changes!!! It should work as it does now for current user flows. I was going to add the ability to change it on input Triggered but decided to let users sort it out with a switch node. they then can pipe it to the IPv4 or IPv6 one they have set.

  • Node status - while I'm here updating this node do we want to add status msg's to this node? someting like. blue_dot IPv6 - 12ms , red_dot false

  • Input and or Output msg.InternetProtocolVersion - I don't want to add this and I don't think I will for the first Pull request I send up the chain. If there is enough demand and @dceejay says "DO IT" I can add the ability to set the Protocol via a input msg and the output msg would let users know what version is selected via the drop down and or sent via input msg.

I'm doing this the proper way using the locals. If there is a Japanese speaker here please let me know now and I can update it if you don't know how to code or submit a pull request that's fine ill do all that. Just need help in the translation.

All sounds sensible steps so far, keeping them separate is sensible as the target can be a list so trying to handle different per each would be a pain..
Status maybe, but again how would you handle a list of targets ? So maybe not.. But by all means set the label to ping6 if appropriate.
We can get translations done when you raise the PR as it will be easy to see the missing fields... Or indeed add them to the other locales in English to make them obvious..

Oh the joy of making things cross platform compatible.

So I have to use a automatic as @leoneltoledo suggested as it would create a breaking change if i force windows users with a -4 for IPv4. however linux users like me have been using ping for IPv4 stuff and ping6 for IPv6.....there is no Auto/Default fallback.

however arch based dist uses -6 so I'm going with Auto for now and figuring out how to deal with all these operating systems.....

Working on how

Fired up a server instance as I could not trust my double NAT network from home. Sorted out ipv6 networking on server and here are the results for Linux for any one who wants to know.

Ubuntu 20.04

ping will default to ipv6 if its avalible

ping6 as expected

ping -6* also works ... interesting

ping -4 forces ipv4

Now knowing how it works I can move on to code........
Info for who ever might want to know

1 Like

OH and i missed that ping6 was merged into ping years ago :stuck_out_tongue:
https://github.com/iputils/iputils/commit/ebad35fee3de851b809c7b72ccc654a72b6af61d

For Windows, ping6 doesn't exist. All other commands listed work in the same way. (ping without modifiers will also default to ipv6 if it is available)

1 Like

Request help from mac OSX guys....

So the command ping -t is the timeout but...
ping6 in mac has no timeout ??? ---> https://www.unix.com/man-page/osx/8/ping6/
unlike in linux -w is not the timeout for OSX ping6

FreeBSD has merged ping6 and ping as of late 2019 and it looks like OSX will follow that soon. So I've coded it up to bank on that fact.

Pull request sent ---> https://github.com/node-red/node-red-nodes/pull/758

for everyone else who wants to test I will post the files here in an hour.

1 Like

To join in the English beta testing of these changes you need to download or have installed:
node-red-node-ping ---> node-red-node-ping (node) - Node-RED

Then in your Node-RED user directory - typically ~/.node-red
find /node_modules dir and in that directory find /node-red-node-ping directory
on linux. The path for me looks like /home/meeki/.node-red/node_modules/node-red-node-ping

You need to overwrite 88-ping.html and 88-ping.js

Then in the /locales/en-US folder ; for me its located at path /home/meeki/.node-red/node_modules/node-red-node-ping/locales/en-US you need to overwrite 88-ping.html and 88-ping.json
then restart node-red
NOTE: 88-ping.html is the same name as the file above but its contents are not. Use the correct file from downloads below!

the files ---> https://filebin.net/1mnsil8x35575pd5
the /locales/en-US files ---> https://filebin.net/c1h9ihd5ixf5g6je

let me know if you have issues

PS: as always I will post about security. Even though you can read what the code does, you may not understand it.

SECURITY NOTE: I see people just willy nilly downloading files. You don't know me. I don't have a community of checkers making sure I'm not bitcoin mining.

Before you download ask yourself if you really should trust the source. If you feel fine then great, but do question before downloading any file that is not official.

If you don't understand the code think twice.