UDP port monitoring? Not done this with NR as yet, but instance issue? Permissions? The node states that you need to be root to use the node for ports below 1000. Which makes sense. The question is, has anyone avoided this, without running NR under root? If someone has figured out way to do this, would save me some effort, thanks.
Is it as simple as using...
$ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/node
Of course paths can vary but my node path is /usr/bin/node. Of course this method has its own issues and risks, but that aside, seems the way to do it?
Not tried it but something like that should work. Also worth noting that a service starting via systemd can have different permissions. Probably worth checking out how something like NGINX is launched since it has access to low TCP port numbers but runs under a non-privileged user.
I got it working. Just clearing it up a bit. Then will post it. I wanted to confirm that WOL packets were being sent, so this seemed the way to do it in NR. I could have used and exec node and tcpdump.... but that is not very NR now is it?
This flow lets you enable access to port 9, check configuration and then release the permissions to access port 9 from within NR, i..e node. Enable port 9 permissions, then generate the WOL packets, and watch them appear via the UDP node. You will need the target MAC address of course.
[{"id":"991187cc4694045f","type":"udp in","z":"fb9e20e6add37970","name":"Wake","iface":"","port":"9","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":190,"y":1360,"wires":[["11fae7c1b9c921fd"]]},{"id":"4134895bda616aca","type":"exec","z":"fb9e20e6add37970","command":"sudo setcap 'cap_net_bind_service=+ep' /usr/bin/node","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Set","x":350,"y":1420,"wires":[["ca3ebbf9b70db554"],[],[]]},{"id":"64a66b9eb5f86111","type":"exec","z":"fb9e20e6add37970","command":"sudo setcap 'cap_net_bind_service=-ep' /usr/bin/node","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"!Set","x":350,"y":1540,"wires":[["61495ac9572cdb44"],[],[]]},{"id":"5162bb449291338f","type":"debug","z":"fb9e20e6add37970","name":"Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":1440,"wires":[]},{"id":"5c33efaf63a98e2c","type":"exec","z":"fb9e20e6add37970","command":"sudo getcap /usr/bin/node","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Get","x":350,"y":1480,"wires":[["48a6686651dfbbca"],[],[]]},{"id":"48a6686651dfbbca","type":"link out","z":"fb9e20e6add37970","name":"","mode":"link","links":["44b31a43029d9dc1"],"x":455,"y":1480,"wires":[]},{"id":"ca3ebbf9b70db554","type":"link out","z":"fb9e20e6add37970","name":"","mode":"link","links":["fa4e01ddbe605a0f","44b31a43029d9dc1"],"x":455,"y":1420,"wires":[]},{"id":"61495ac9572cdb44","type":"link out","z":"fb9e20e6add37970","name":"","mode":"link","links":["44b31a43029d9dc1"],"x":455,"y":1540,"wires":[]},{"id":"2e769b22b18d8646","type":"inject","z":"fb9e20e6add37970","name":"Enable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1420,"wires":[["4134895bda616aca"]]},{"id":"1390286364b23692","type":"inject","z":"fb9e20e6add37970","name":"Disable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1540,"wires":[["64a66b9eb5f86111"]]},{"id":"2922fe46075cd512","type":"inject","z":"fb9e20e6add37970","name":"Status","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1480,"wires":[["5c33efaf63a98e2c"]]},{"id":"300440938189f679","type":"wake on lan","z":"fb9e20e6add37970","mac":"XX:XX:XX:XX:XX:XX","host":"","udpport":9,"numpackets":"15","interval":"1000","name":"Wake On LAN","x":380,"y":1300,"wires":[]},{"id":"b5e8b044776f8c03","type":"comment","z":"fb9e20e6add37970","name":"sudo tcpdump -i enxb827eb1936bf '(udp and port 7) or (udp and port 9)' -x | tee wol.log","info":"","x":440,"y":1600,"wires":[]},{"id":"18ea2407f8fbd066","type":"comment","z":"fb9e20e6add37970","name":"nc -ul 9","info":"","x":190,"y":1640,"wires":[]},{"id":"3797aa2325b64307","type":"comment","z":"fb9e20e6add37970","name":"nc -ul -p 9","info":"","x":200,"y":1680,"wires":[]},{"id":"152b7478996c1c3c","type":"comment","z":"fb9e20e6add37970","name":"tcpdump -UlnXi enxb827eb1936bf ether proto 0x0842 or udp port 9 2>/dev/null | sed -nE 's/^.*20: (ffff|.... ....) (..)(..) (..)(..) (..)(..).*$/\\2:\\3:\\4:\\5:\\6:\\7/p'","info":"","x":630,"y":1720,"wires":[]},{"id":"fdb318460c0baca4","type":"inject","z":"fb9e20e6add37970","name":"Inject","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1300,"wires":[["300440938189f679"]]},{"id":"44b31a43029d9dc1","type":"link in","z":"fb9e20e6add37970","name":"","links":["b8b9150a37c223ce","ca3ebbf9b70db554","48a6686651dfbbca","61495ac9572cdb44"],"x":525,"y":1440,"wires":[["5162bb449291338f"]]},{"id":"b8b9150a37c223ce","type":"link out","z":"fb9e20e6add37970","name":"","mode":"link","links":["44b31a43029d9dc1"],"x":455,"y":1360,"wires":[]},{"id":"11fae7c1b9c921fd","type":"function","z":"fb9e20e6add37970","name":"Convert","func":"function ConvertByteArrayToHexString(theArray) {\n return Array.from(theArray, function(theByte) {\n return ('0'+(theByte & 0xFF).toString(16)).slice(-2).toUpperCase();\n }).join(':')\n}\n\nmsg.payload=ConvertByteArrayToHexString(msg.payload.slice(96,102));\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1360,"wires":[["b8b9150a37c223ce"]]}]
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.