SR-G / sleep-on-lan

Multi-platform process allowing to sleep on LAN a linux or windows computer, through wake-on-lan (reversed) magic packets or through HTTP REST requests.
Apache License 2.0
332 stars 25 forks source link

Discard invalid packets #52

Closed skrimix closed 1 year ago

skrimix commented 1 year ago

When receiving an invalid packet sleep-on-lan logs an error, but still proceeds with comparing an empty string and sending the PC to sleep. Something is sending 0 len packets on my system and my PC goes to sleep randomly. These changes fix the issue.

I'm not a Go dev, so not 100% sure that what I'm doing is correct, but I tested for a while and everything seems to work

SR-G commented 1 year ago

I agree, the code was not robust here (and i've never encountered the weird packets you have seen on your side). Thanks for the PR.