Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customizable way of waking hosts through webhooks pls? #1251

Open
shawly opened this issue Apr 9, 2024 · 2 comments
Open

Add customizable way of waking hosts through webhooks pls? #1251

shawly opened this issue Apr 9, 2024 · 2 comments

Comments

@shawly
Copy link

shawly commented Apr 9, 2024

Is your feature request related to a problem? Please describe.

Wake on LAN is pretty unstable on my gaming rig, especially if it was turned off for a while.
I created a custom pcb with an ESP8266 (running esphome) that sits between my motherboard and front panel that can turn my PC on and off through Home Assistant, which works fantastic.

But that means I have to log in to Home Assistant and turn on the PC from there, I can't just wake the PC through Moonlight.

That's why I'm currently trying to capture magic packets with my little ESP so I can trigger custom actions that react if a specific magic packet is sent to the ESP or broadcast address which I actually had some success with.

The problem is, that if I'm not at home and try to send a magic packet through Moonlight, Moonlight sends it to all unique addresses in the config (https://github.com/moonlight-stream/moonlight-qt/blob/v5.0.1/app/backend/nvcomputer.cpp#L466).
This means that my ESP will technically never receive the packet if I'm not at home.
I did get it to work by editing my moonlight.conf and adding the ESPs IP address to the remoteAddress property, so my ESP does receive the packet since Moonlight directly sends it to that IP.

Describe the solution you'd like

I'd really love if there was a customizable way in Moonlight for waking hosts. Since there are a lot of ways that could be done, I think the most universal way would be to add something like webhooks.
So one could add a global webhook to moonlight which gets called whenever a host must be woken. The request should send data like the IP, name and mac of the host so whoever receives that data can handle waking up the host in whatever way possible.

With the versatility of webhooks, a user could implement a custom wake functionality however they want. One could implement a WoL relay server which receives the HTTP request and then sends a magic packet in their home network.
Or one could use NodeRED to implement a server that receives the data from the webhook and can execute whatever they want.

This functionality could also easliy be ported to every other Moonlight implementation as well!

Describe alternatives you've considered
Well, for me personally it would be enough if there was a custom field wolAddress in the config where I can just add the IP of my ESP which will be added to the list of IPs that get magic packets from Moonlight. But adding the wolAddress on my hacked switch might be difficult, at least with the moonlight-switch homebrew.

@cgutman
Copy link
Member

cgutman commented Apr 13, 2024

Moonlight also sends WoL magic packets to a couple of other ports that aren't involved in streaming (UDP ports 9 and 47009). If your ESP can act as a general WoL relay (which it sounds like it can), you can just forward one or both of those ports to your ESP's IP address instead of your host PC and that should allow your WoL relay to work.

@shawly
Copy link
Author

shawly commented Apr 13, 2024

Hmm on a connection between two Wireguard hosts this could work maybe, but my site to site VPN runs between two FRITZ!Boxes and they don't generally provide any capabilities of manipulating iptables, so that solution is off the table I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants