wol

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wol builds and sends Wake-on-LAN magic packets. It imports only the standard library so both sqi-server and sqi-worker can use it.

Index

Constants

View Source
const (
	// DefaultPort is the conventional Wake-on-LAN UDP port (discard).
	DefaultPort = 9
	// DefaultBurst is how many copies of each packet are sent; UDP gives no
	// delivery guarantee, and a sleeping NIC only needs one to arrive.
	DefaultBurst = 3
	// DefaultGap is the pause between bursts.
	DefaultGap = 100 * time.Millisecond
)

Variables

This section is empty.

Functions

func DirectedBroadcast

func DirectedBroadcast(cidr string) (net.IP, bool)

DirectedBroadcast returns the IPv4 subnet-directed broadcast address of cidr ("192.168.1.20/24" gives 192.168.1.255). ok is false for IPv6, for /31 and /32 (which have no broadcast address), and for input that does not parse.

func MagicPacket

func MagicPacket(mac net.HardwareAddr) ([]byte, error)

MagicPacket returns the 102-byte magic packet for mac: six 0xFF bytes followed by the 6-byte MAC repeated 16 times. It is an error unless mac is exactly 6 bytes.

func Send

func Send(ctx context.Context, macs []net.HardwareAddr, targets []string, burst int, gap time.Duration) (reached int, err error)

Send sends burst copies of each MAC's magic packet to each target ("ip:port"), gap apart, over UDP with SO_BROADCAST set, and reports how many targets it reached: those at least one packet write to succeeded. A bad MAC, an unresolvable target or a failed write is recorded and Send keeps going; the returned error joins every one of them, so a caller can count a send that reached some targets as done and still log the rest. A canceled ctx stops Send early and its error is joined in too.

func SendDefault

func SendDefault(ctx context.Context, macs []net.HardwareAddr, targets []string) (reached int, err error)

SendDefault is Send with DefaultBurst and DefaultGap.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL