apply

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const HealthHysteresisBandaid = 10 * time.Second

HealthHysteresisBandaid is an extra delay to add before considering a peer unhealthy, based on as-yet undiagnosed observations of handshakes not refreshing as often as documentation seems to suggest they should

Variables

This section is empty.

Functions

func EnsureAllowedIPs

func EnsureAllowedIPs(ctrl *wgctrl.Client, deviceName string, peer *wgtypes.Peer, facts []*fact.Fact) (added int, err error)

EnsureAllowedIPs updates the device config if needed to add all the AllowedIPs from the facts to the peer

func EnsurePeerAutoIP

func EnsurePeerAutoIP(ctrl *wgctrl.Client, dev *wgtypes.Device) (int, error)

EnsurePeerAutoIP updates the config of the device, if needed, to ensure all peers have their IPv6-LL IP listed in their AllowedIPs. It returns the number of peers modified and any error that happens

func OnlyAutoIP

func OnlyAutoIP(ctrl *wgctrl.Client, deviceName string, peer *wgtypes.Peer) (bool, error)

OnlyAutoIP configures a peer to have _only_ its IPv6-LL IP in its AllowedIPs it returns whether a change was attempted and any error that happens

Types

type Manager

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

Manager is a wrapper for applying local configuration changes

func NewManager

func NewManager() (*Manager, error)

NewManager instantiates a new Manager object with its own netlink handle

func (*Manager) EnsureLocalAutoIP

func (m *Manager) EnsureLocalAutoIP(dev *wgtypes.Device) (bool, error)

EnsureLocalAutoIP makes sure that the automatic IPv6 link-local IP is present on the interface that matches the device It returns whether it had to add it, and if any errors happened

type PeerConfigState

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

PeerConfigState stores state to remember peer info so we can cycle through configurations effectively

func (*PeerConfigState) IsAlive added in v0.0.2

func (pcs *PeerConfigState) IsAlive() bool

IsAlive returns if the peer looked alive on the last call to `Update`. note that a peer can be alive but unhealthy!

func (*PeerConfigState) IsHealthy

func (pcs *PeerConfigState) IsHealthy() bool

IsHealthy returns if the peer looked healthy on the last call to `Update`

func (*PeerConfigState) NextEndpoint

func (pcs *PeerConfigState) NextEndpoint(peerFacts []*fact.Fact) *net.UDPAddr

NextEndpoint recommends the next endpoint to try configuring on the peer, if any, based on the available facts (assumed to all be about the peer!) Note that this does _not_ embed the logic for whether a new endpoint _should_ be attempted (i.e. it doesn't call `TimeForNextEndpoint` internally).

func (*PeerConfigState) TimeForNextEndpoint

func (pcs *PeerConfigState) TimeForNextEndpoint() bool

TimeForNextEndpoint returns if we should try another endpoint for the peer (or if we should wait for the current endpoint to test out)

func (*PeerConfigState) Update

func (pcs *PeerConfigState) Update(peer *wgtypes.Peer, newAlive bool) *PeerConfigState

Update refreshes the PeerConfigState with new data from the wireguard device. NOTE: It is safe to call this on a `nil` pointer, it will return a new state TODO: give this access to the `peerKnowledgeSet` instead of passing in the alive state

Jump to

Keyboard shortcuts

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