wireguard

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeys

func GetKeys(secretName, namespace string, c k8s.Interface) (priv, pub wgtypes.Key, err error)

func NewWgClient

func NewWgClient() (*wgClient, error)

func NewWgClientFake

func NewWgClientFake(deviceName string) (*wgClientFake, error)

Types

type Client

type Client interface {
	// contains filtered or unexported methods
}

a simple interface that implements some of the methods of wgctrl.Client interface. a fake implementation is used for the unit tests

type Netlinker

type Netlinker interface {
	// contains filtered or unexported methods
}

func NewNetLinker

func NewNetLinker() Netlinker

func NewNetLinkerFake

func NewNetLinkerFake(errOnCreate, errOnAddIP, errOnSetMtu bool) Netlinker

type WgConfig

type WgConfig struct {
	Name      string       //device name
	IPAddress string       //ip address in CIDR notation (x.x.x.x/xx)
	Mtu       int          //mtu to be set on interface
	Port      *int         //listening port
	PriKey    *wgtypes.Key //private key
	PubKey    *wgtypes.Key //public key
}

type Wireguard

type Wireguard struct {
	Client    // client used to interact with the wireguard implementation in use
	Netlinker // the wireguard link living in the network namespace
	// contains filtered or unexported fields
}

func NewWireguard

func NewWireguard(config WgConfig, c Client, nl Netlinker) (*Wireguard, error)

func (*Wireguard) AddPeer

func (w *Wireguard) AddPeer(pubkey, endpointIP, listeningPort string, allowedIPs []string, keepAlive *time.Duration) error

it adds a new peer with the given configuration to the wireguard device

func (*Wireguard) GetDeviceName

func (w *Wireguard) GetDeviceName() string

get name of the wireguard device

func (*Wireguard) GetLinkIndex

func (w *Wireguard) GetLinkIndex() int

get link index of the wireguard device

func (*Wireguard) GetPubKey

func (w *Wireguard) GetPubKey() string

get public key of the wireguard device

func (*Wireguard) RemovePeer

func (w *Wireguard) RemovePeer(pubKey string) error

it removes a peer with a given public key from the wireguard device

Jump to

Keyboard shortcuts

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