wireguard

package
v0.4.5-1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 12 Imported by: 1

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 added in v0.4.0

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