Documentation
¶
Overview ¶
Package wol implements a Wake-on-LAN client.
Index ¶
Constants ¶
const ( // EtherType is the registered EtherType for Wake-on-LAN over Ethernet. // See: https://wiki.wireshark.org/WakeOnLAN. EtherType = 0x0842 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MagicPacket ¶
type MagicPacket struct {
// Target specifies the hardware address of a LAN device to wake using
// this MagicPacket.
Target net.HardwareAddr
// Password specifies an optional password for this MagicPacket. Password
// must be exactly 0 (empty), 4, or 6 bytes in length.
Password []byte
}
A MagicPacket is a Wake-on-LAN packet. It specifies a target hardware address to wake, and optionally, a password used to authenticate the MagicPacket wake request.
func (*MagicPacket) MarshalBinary ¶
func (p *MagicPacket) MarshalBinary() ([]byte, error)
MarshalBinary allocates a byte slice and marshals a MagicPacket into binary form.
If p.Target is not exactly 6 bytes in length, errInvalidTarget is returned.
If p.Password is not exactly 0 (empty), 4, or 6 bytes in length, errInvalidPassword is returned.
func (*MagicPacket) UnmarshalBinary ¶
func (p *MagicPacket) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals a byte slice into a MagicPacket.
If the byte slice does not contain enough data to unmarshal a valid MagicPacket, io.ErrUnexpectedEOF is returned.
type RawClient ¶
type RawClient struct {
// contains filtered or unexported fields
}
A RawClient is a Wake-on-LAN client which operates directly on top of Ethernet frames using Ethernet sockets. It can be used to send WoL magic packets to other machines on a local network, using their hardware addresses.
func NewRawClient ¶
NewRawClient creates a new RawClient using the specified network interface.
Note that Ethernet sockets typically require elevated user privileges, such as the 'root' user on Linux, or the 'SET_CAP_RAW' capability.
For this reason, it is typically recommended to use the regular Client type instead, which operates over UDP.
func (*RawClient) Wake ¶
func (c *RawClient) Wake(target net.HardwareAddr) error
Wake sends a Wake-on-LAN magic packet to the specified hardware address.
func (*RawClient) WakePassword ¶
func (c *RawClient) WakePassword(target net.HardwareAddr, password []byte) error
WakePassword sends a Wake-on-LAN magic packet to the specified hardware address, using the specified Password.
The password must be exactly 0 (empty), 4, or 6 bytes in length.