swireguard

package
v0.6.3-beta01 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

* swireguard package is wireguard on steroids super-wireguard, smart-wireguar, Syntropy-wireguard This package is a helper for agent to configure (kernel or userspace) wireguard tunnels It also collects peer status, monitores latency, and other releated work *

Index

Constants

View Source
const KeepAlliveDuration = 15 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type InterfaceInfo

type InterfaceInfo struct {
	IfName    string
	PublicKey string

	IP   netip.Addr
	Port int
	// contains filtered or unexported fields
}

func (*InterfaceInfo) Peers

func (ii *InterfaceInfo) Peers() []*PeerInfo

type PeerInfo

type PeerInfo struct {
	IfName       string
	PublicKey    string
	ConnectionID int
	GroupID      int
	AgentID      int
	IP           netip.Addr
	Port         int
	Gateway      netip.Addr
	AllowedIPs   []netip.Prefix
	Stats        PeerStats
}

type PeerStats

type PeerStats struct {
	TxBytesTotal  int64
	RxBytesTotal  int64
	TxBytesDiff   int64
	RxBytesDiff   int64
	TxSpeedMBps   float32
	RxSpeedMBps   float32
	LastHandshake time.Time
	// contains filtered or unexported fields
}

type Wireguard

type Wireguard struct {
	// If true - remove resident non-syntropy created tunnels
	RemoveNonSyntropyInterfaces bool

	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New() (*Wireguard, error)

New creates new instance of Wireguard configurer and monitor

func (*Wireguard) AddPeer

func (wg *Wireguard) AddPeer(pi *PeerInfo) error

AddPeer adds a peer to Wireguard interface and internal cache

func (*Wireguard) Apply

func (wg *Wireguard) Apply() (allowedIPs []netip.Prefix, err error)

Apply function setups cached WG configuration, and cleans up resident configuration

func (*Wireguard) Close

func (wg *Wireguard) Close() error

func (*Wireguard) CreateInterface

func (wg *Wireguard) CreateInterface(ii *InterfaceInfo) error

func (*Wireguard) Device

func (wg *Wireguard) Device(ifname string) *InterfaceInfo

func (*Wireguard) Devices

func (wg *Wireguard) Devices() []*InterfaceInfo

func (*Wireguard) Flush

func (wg *Wireguard) Flush()

Flush clears all WG local cache

func (*Wireguard) LogInfo

func (wg *Wireguard) LogInfo()

func (*Wireguard) PeerStatsInit

func (wg *Wireguard) PeerStatsInit()

func (*Wireguard) PeerStatsUpdate

func (wg *Wireguard) PeerStatsUpdate()

func (*Wireguard) RemoveInterface

func (wg *Wireguard) RemoveInterface(ii *InterfaceInfo) error

func (*Wireguard) RemovePeer

func (wg *Wireguard) RemovePeer(pi *PeerInfo) error

RemovePeer removes a peer from Wireguard interface and internal cache

Jump to

Keyboard shortcuts

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