wireguard

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(dir string) (wgtypes.Key, error)

GenerateKey generates a new private key. If key already exists in that location, that key is returned instead.

func LoadKey

func LoadKey(dir string) (wgtypes.Key, error)

LoadKey tries to read a private key from disk

Types

type Peer

type Peer struct {
	PublicKey  string
	Endpoint   string
	AllowedIPs []string
}

Peer represent a peer in a wireguard configuration

type Wireguard

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

Wireguard is a netlink.Link of type wireguard

func GetByName

func GetByName(name string) (*Wireguard, error)

GetByName return a wireguard object by its name

func New

func New(name string) (*Wireguard, error)

New create a new wireguard interface

func (*Wireguard) Attrs

func (w *Wireguard) Attrs() *netlink.LinkAttrs

Attrs implements the netlink.Link interface

func (*Wireguard) Configure

func (w *Wireguard) Configure(privateKey string, listentPort int, peers []*Peer) error

Configure configures the wiregard configuration

func (*Wireguard) Device

func (w *Wireguard) Device() (*wgtypes.Device, error)

Device returns the detail of the configuration of the wireguard interface

func (*Wireguard) SetAddr

func (w *Wireguard) SetAddr(cidr string) error

SetAddr sets an IP address on the interface

func (*Wireguard) Type

func (w *Wireguard) Type() string

Type implements the netlink.Link interface

func (*Wireguard) UnsetAddr

func (w *Wireguard) UnsetAddr(cidr string) error

UnsetAddr removes an IP address from the interface

Jump to

Keyboard shortcuts

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