wireguard

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package wireguard manages user-space Wireguard interface.

Index

Constants

View Source
const PeerDownInterval = (180 + 5 + 90) * time.Second

PeerDownInterval is the time since last handshake when established peer is considered to be down.

WG whitepaper defines a downed peer as being: Handshake Timeout (180s) + Rekey Timeout (5s) + Rekey Attempt Timeout (90s)

This interval is applied when the link is already established.

Variables

This section is empty.

Functions

func NetworkPrefix

func NetworkPrefix(installationID string) netaddr.IPPrefix

NetworkPrefix returns IPv6 prefix for the SideroLink.

Server is using the first address in the block. Nodes are using random addresses from the /64 space.

func UAPIOpen added in v0.1.1

func UAPIOpen(interfaceName string) (net.Listener, error)

UAPIOpen opens a UAPI socket.

Types

type Device

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

Device manages Wireguard link.

func NewDevice

func NewDevice(address netaddr.IPPrefix, privateKey wgtypes.Key, listenPort uint16) (*Device, error)

NewDevice creates a new device with settings.

func (*Device) Close

func (dev *Device) Close() error

Close the device.

func (*Device) Peers added in v0.1.2

func (dev *Device) Peers() ([]wgtypes.Peer, error)

Peers returns underlying peer states from the underlying wireguard device.

func (*Device) Run

func (dev *Device) Run(ctx context.Context, logger *zap.Logger, peers PeerSource) error

Run the device.

type PeerEvent

type PeerEvent struct {
	PubKey wgtypes.Key

	Remove   bool
	Endpoint string

	Address netaddr.IP
}

PeerEvent is the event about peer state change.

type PeerSource

type PeerSource interface {
	EventCh() <-chan PeerEvent
}

PeerSource is the interface of the "database" providing SideroLink peer information.

Jump to

Keyboard shortcuts

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