Fix Wake-on-LAN: Implement custom WOL with OS-specific broadcast support
This commit is contained in:
20
internal/wol/enable_broadcast_unix.go
Normal file
20
internal/wol/enable_broadcast_unix.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user