For my home automation system, I’d like to run gnatsd (https://nats.io/) as a sidecar to all of the nodes I connect to the network and have each gnatsd automatically cluster with the other nodes present. This way, all of the applications can simply send and receive messages to the local gnatsd instance and be reasonably sure that the applications that need the messages can get them. So far I’ve come up with this short bit of Go: https://gist.github.com/alittlebrighter/c1c124b0c5f70e11e7103c44baefcb3d which basically just uses a nats client to try and connect to all of the nodes on the network and then return the IPs of the ones that were successful and shell out a command to start up gnatsd with the other node IPs as command line arguments.
Is there a better way to do this? Any and all suggestions are welcome.
I understand there are potential security issues with this, this is all happening on my local secured network and I’m not concerned about hackers.