Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.26k stars 569 forks source link

Use a port for server-generated WoL packets to support docker configuration. #6419

Open AlexCherrypi opened 1 month ago

AlexCherrypi commented 1 month ago

Is your feature request related to a problem? Please describe. I use MeshCentral in a docker container. I want to use WoL when the server is the only awake device in the Lan. Therefore I need a port that I can forward in docker so WoL (magic packet sent by server) works.

Describe the solution you'd like You could specify a port for the UDP WoL Magic Packet. You could do it like this: socket.bind({ address: addr.address, port: 9 });

But why port 9? Look here!

I might just create a pull request later, but right now I am lying in bed and just remembered this issue. So I found a potential fix. But I really don't want to get up to create the pull request right now. Good night!

si458 commented 1 month ago

To use wol i believe you need to use the host network mode in docker As it needs to send the packets with mac address etc to a broadcast address and this won't work if u use bridge mode because it creates its own network which wouldn't be able to access ur home network

AlexCherrypi commented 1 month ago

I'll try it out later and report back.

si458 commented 1 month ago

Also if I remember WOL works by meshcentral asking remote devices within a meshgroup that is online to send out the WOL packets to the device u want waking up, so I don't think the meshcentral server itself can wake the remote devices up

AlexCherrypi commented 1 month ago

As far as I know, it does send WOL packets if in Lan or Hybrid mode.

Regarding the docker thing: way to much work. You'd have to specify the broadcast address manually and make the system not ignore invalid broadcast packets for the network it is connected to.

But: specifying a port nevertheless is a good idea, especially for network monitoring / packet inspection.

si458 commented 1 month ago

ok so just looked at this, this is the line where it sends the packets https://github.com/Ylianst/MeshCentral/blob/19d0df7e7f025823bf85eb10aa000489e41c01ec/agents/meshcore.js#L1001 so do we simply need to change 7 to 9 im guessing? if thats the case, i think we can add a value inside of config.json like "wolport9": true and if this value is true, we then use port 9 instead of 7 !?

AlexCherrypi commented 1 month ago

I think so.

But what exactly is the difference between sendWakeOnLanEx_interval() and sendWakeOnLanEx(hexMacList) ?

Both functions send WoL packets...

I am just wondering if both have to be changed.