Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device interface { // SetKey sets the private key of the WireGuard interface. SetKey(privateKey wgtypes.Key) error // SetListenPort sets the listening port of the WireGuard interface. SetListenPort(port uint16) error // SetIP sets the IP of the WireGuard interface. SetIP(newIP *net.IPNet) error // SetState sets the state of the WireGuard interface to "up" (true) or // "down" (false). // // A "down" WireGuard interface will be unable to handle any traffic. SetState(up bool) error // AddPeer adds a new peer or updates existing peer information. // // A Peer already exists when a peer with the same key as publicKey has // been previously added to the interface. // // endpoint may be nil, and ip may be empty, but not at the same time. // publicKey must always be specified. AddPeer(ip *net.IPNet, endpoint *net.UDPAddr, publicKey wgtypes.Key) error // RemovePeer disconnects from the specified peer by their public key. // // If the public key is not found in an existing peer, this function // does nothing. RemovePeer(publicKey wgtypes.Key) error // Interface returns the underlying interface. Interface() ifctl.Interface // Close closes the WireGuard interface and cleans up. Close() error }
Device implements an interface to a WireGuard device, whether it be an in-kernel implementation or based upon wireguard-go.
A Device is not thread-safe. Always use a mutex when using a device from multiple goroutines.
Click to show internal directories.
Click to hide internal directories.