Fix Wake-on-LAN: Implement custom WOL with OS-specific broadcast support

This commit is contained in:
2025-08-21 14:15:15 +02:00
parent 0f317d4c9e
commit 4a56cbd310
4 changed files with 209 additions and 54 deletions

View File

@@ -0,0 +1,20 @@
//go:build !windows
package wol
import (
"net"
"syscall"
)
func enableBroadcast(conn *net.UDPConn, debug bool) error {
raw, err := conn.SyscallConn()
if err != nil {
return err
}
var setErr error
raw.Control(func(fd uintptr) {
setErr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
})
return setErr
}