wireguard

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPeerConfig

func NewPeerConfig(publicKey string, presharedKey string, endpoint string, allowedIPs []string) (*wgtypes.PeerConfig, error)

NewPeerConfig constructs and returns a wgtypes PeerConfig object.

func SetPeers

func SetPeers(deviceName string, peers []wgtypes.PeerConfig) error

SetPeers takes a device name and a list of peers and updates the device's peers list to match the passed one.

Types

type Device

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

Device is the struct to hold the link device and the wireguard attributes we need.

func NewDevice

func NewDevice(name string, keyFilename string, mtu, listenPort int) *Device

NewDevice returns a new device struct.

func (*Device) AddRouteToNet

func (d *Device) AddRouteToNet(subnet *net.IPNet) error

AddRouteToNet adds a route to the passed subnet via the device

func (*Device) Configure

func (d *Device) Configure() error

Configure configures wireguard keys and listen port on the device.

func (*Device) EnsureLinkUp

func (d *Device) EnsureLinkUp() error

EnsureLinkUp brings up the wireguard device.

func (*Device) FlushAddresses

func (d *Device) FlushAddresses() error

FlushAddresses deletes all ips from the device network interface

func (*Device) ListenPort

func (d *Device) ListenPort() int

ListenPort returns the wg listen port

func (*Device) Name

func (d *Device) Name() string

Name returns the name of the device.

func (*Device) PublicKey

func (d *Device) PublicKey() string

PublicKey returns the device's wg public key

func (*Device) Run

func (d *Device) Run() error

Run creates the wireguard device or sets mtu and txqlen if the device exists.

func (*Device) UpdateAddress

func (d *Device) UpdateAddress(address *net.IPNet) error

UpdateAddress will patch the device interface so it is assigned only the given address.

Jump to

Keyboard shortcuts

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