wgctrl – golang.zx2c4.com/wireguard/wgctrl Index | Files | Directories

package wgctrl

import "golang.zx2c4.com/wireguard/wgctrl"

Package wgctrl enables control of WireGuard devices on multiple platforms.

For more information on WireGuard, please see https://www.wireguard.com/.

This package implements WireGuard configuration protocol operations, enabling the configuration of existing WireGuard devices. Operations such as creating WireGuard devices, or applying IP addresses to those devices, are out of scope for this package.

Index

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client provides access to WireGuard device information.

func New

func New() (*Client, error)

New creates a new Client.

func (*Client) Close

func (c *Client) Close() error

Close releases resources used by a Client.

func (*Client) ConfigureDevice

func (c *Client) ConfigureDevice(name string, cfg wgtypes.Config) error

ConfigureDevice configures a WireGuard device by its interface name.

Because the zero value of some Go types may be significant to WireGuard for Config fields, only fields which are not nil will be applied when configuring a device.

If the device specified by name does not exist or is not a WireGuard device, an error is returned which can be checked using `errors.Is(err, os.ErrNotExist)`.

func (*Client) Device

func (c *Client) Device(name string) (*wgtypes.Device, error)

Device retrieves a WireGuard device by its interface name.

If the device specified by name does not exist or is not a WireGuard device, an error is returned which can be checked using `errors.Is(err, os.ErrNotExist)`.

func (*Client) Devices

func (c *Client) Devices() ([]*wgtypes.Device, error)

Devices retrieves all WireGuard devices on this system.

Source Files

client.go doc.go os_linux.go

Directories

PathSynopsis
cmd
cmd/wgctrlCommand wgctrl is a testing utility for interacting with WireGuard via package wgctrl.
internal
wgtypesPackage wgtypes provides shared types for the wgctrl family of packages.
Version
v0.0.0-20241231184526-a9ab2273dd10 (latest)
Published
Dec 31, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
1 month ago

Tools for package owners.