wireguard

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package wireguard manipulates wireguard interfaces

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrModuleNotFound = errors.New("module not found")
)

Functions

func AddAddresses

func AddAddresses(node *config.Node)

AddAddress adds a nodes addresses (v4 and v6) to interface section of wg config file

func ApplyWithoutWGQuick

func ApplyWithoutWGQuick(nc *NCIface) error

ApplyWithoutWGQuick - Function for running the equivalent of "wg-quick up" for linux if wg-quick is missing

func DeleteOldInterface added in v0.18.3

func DeleteOldInterface(iface string)

DeleteOldInterface - removes named interface

func IfaceDelta

func IfaceDelta(currentNode *config.Node, newNode *config.Node) bool

IfaceDelta - checks if the new node causes an interface change

func IfaceExists

func IfaceExists(ifacename string) bool

IfaceExists - return true if you can find the iface

func RemovePeer

func RemovePeer(n *config.Node, p *wgtypes.PeerConfig) error

RemovePeer replaces a wireguard peer temporarily making public func to pass staticchecks this function will be required in future when add/delete node on server is refactored

func RemovePeers

func RemovePeers(node *config.Node) error

RemovePeers - removes all peers from a given node config

func RemoveWithoutWGQuick

func RemoveWithoutWGQuick(ifacename string) error

RemoveWithoutWGQuick - Function for running the equivalent of "wg-quick down" for linux if wg-quick is missing

func SetPeers

func SetPeers() error

SetPeers - sets peers on netmaker WireGuard interface

func UpdateKeepAlive

func UpdateKeepAlive(keepalive int) error

UpdateKeepAlive - updates the persistentkeepalive of all peers

func UpdatePeer

func UpdatePeer(p *wgtypes.PeerConfig) error

UpdatePeer replaces a wireguard peer temporarily making public func to pass staticchecks this function will be required in future when update node on server is refactored

func UpdatePrivateKey

func UpdatePrivateKey(file, privateKey string) error

UpdatePrivateKey - updates the private key of a wireguard config file

func UpdateWgInterface

func UpdateWgInterface(node *config.Node, host *config.Config) error

UpdateWgInterface - updates the interface section of a wireguard config file

func UpdateWgPeers

func UpdateWgPeers() (*net.UDPAddr, error)

UpdateWgPeers updates the peers section of wg conf file with a new set of peers

func WgConfExists

func WgConfExists() bool

WgConfExists - checks if Netmaker WireGuard conf exists

func WriteWgConfig

func WriteWgConfig(host *config.Config, nodes config.NodeMap) error

WriteWgConfig - creates a wireguard config file

Types

type NCIface

type NCIface struct {
	Iface     netIface
	Name      string
	Addresses []ifaceAddress
	MTU       int
	Config    wgtypes.Config
}

NCIface - represents a Netclient network interface

func GetInterface

func GetInterface() *NCIface

func NewNCIface

func NewNCIface(host *config.Config, nodes config.NodeMap) *NCIface

NewNCIFace - creates a new Netclient interface in memory

func (*NCIface) ApplyAddrs

func (nc *NCIface) ApplyAddrs(addOnlyRoutes bool) error

netLink.ApplyAddrs - applies the assigned node addresses to given interface (netLink)

func (*NCIface) Close

func (n *NCIface) Close()

NCIface.Close closes netmaker interface

func (*NCIface) Configure

func (n *NCIface) Configure() error

Configure applies configuration to netmaker wireguard interface

func (*NCIface) Create

func (nc *NCIface) Create() error

NCIface.Create - creates a linux WG interface based on a node's host config

func (*NCIface) GetPeerRoutes added in v0.18.3

func (nc *NCIface) GetPeerRoutes()

NCIface.GetPeerRoutes - fetches additional routes that are needed to be added to the interface

func (*NCIface) SetMTU

func (n *NCIface) SetMTU() error

NCIface.SetMTU - sets the mtu for the interface

func (*NCIface) UpdatePeer

func (n *NCIface) UpdatePeer(p wgtypes.PeerConfig)

NCIface.UpdatePeer - Updates Peers from provided PeerConfig

Jump to

Keyboard shortcuts

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