device

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package device wraps the wgctrl library with concurrency safety and dirty tracking to simplify interactions from the wirelink server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device wraps a WgClient and an associated device name

func New

func New(
	ctrl internal.WgClient,
	iface string,
) (*Device, error)

New creates a new device from an already open control interface. The Close() method of the returned Device will be a no-op.

func Take

func Take(
	ctrl internal.WgClient,
	iface string,
) (*Device, error)

Take is the same as New, except that it takes ownership of the control interface if initialization is successful.

func (*Device) Close

func (d *Device) Close() error

Close closes the underlying control interface, if the Device owns it. It is not safe to call Close if other goroutines using the device are active.

func (*Device) ConfigureDevice

func (d *Device) ConfigureDevice(cfg wgtypes.Config) error

ConfigureDevice wraps the underlying wgctrl method

func (*Device) Dirty

func (d *Device) Dirty()

Dirty marks the device state dirty forcing the next read to refresh the data.

func (*Device) EnsurePeersAutoIP

func (d *Device) EnsurePeersAutoIP() (int, error)

EnsurePeersAutoIP updates the config of the device, if needed, to ensure all peers have their IPv6-LL IP listed in their AllowedIPs. It returns the number of peers modified and any error that happens

func (*Device) State

func (d *Device) State() (*wgtypes.Device, error)

State gets the current device state. It will attempt to refresh it if dirty. If refresh fails, it will return the last state along with the refresh error. The returned state will never be nil, because New/Open will refuse to create a Device if they cannot read an initial state.

Jump to

Keyboard shortcuts

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