agent

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 43 Imported by: 1

Documentation

Overview

This package contains the agent code used to configure the WireGuard tunnel between nodes. The code supports adding and removing peers at run-time and the peer information is retrieved via the CiliumNode object.

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"wireguard-agent",
	"Manages WireGuard device and peers",

	cell.Config(defaultUserConfig),
	cell.Provide(newWireguardAgent, newWireguardConfig),
	cell.ProvidePrivate(buildConfigFrom),
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	lock.RWMutex
	// contains filtered or unexported fields
}

Upon starting, the agent will create the WireGuard tunnel device and the proper routes set. Once restoreFinished() is called, obsolete keys and peers, as well as stale AllowedIPs are removed. updatePeer() inserts or updates the public key of peers discovered via the node manager.

func (*Agent) AllNodeValidateImplementation

func (a *Agent) AllNodeValidateImplementation()

AllNodeValidateImplementation is called to validate the implementation of all nodes in the datapath.

func (*Agent) Enabled added in v1.19.0

func (a *Agent) Enabled() bool

Returns true when enabled. Implements types.WireguardAgent.

func (*Agent) IfaceBufferMargins added in v1.19.0

func (a *Agent) IfaceBufferMargins() (uint16, uint16, error)

IfaceBufferMargins() returns the buffer margins of the Wireguard interface.

func (*Agent) IfaceIndex added in v1.19.0

func (a *Agent) IfaceIndex() (uint32, error)

IfaceIndex returns the index of the Wireguard interface.

func (*Agent) Name

func (a *Agent) Name() string

Name implements datapath.NodeHandler.

func (*Agent) NodeAdd

func (a *Agent) NodeAdd(newNode nodeTypes.Node) error

NodeAdd is called when a node is discovered for the first time.

func (*Agent) NodeDelete

func (a *Agent) NodeDelete(node nodeTypes.Node) error

NodeDelete is called after a node has been deleted

func (*Agent) NodeUpdate

func (a *Agent) NodeUpdate(_, newNode nodeTypes.Node) error

NmdeUpdate is called when a node definition changes. Both the old and new node definition is provided. NodeUpdate() is never called before NodeAdd() is called for a particular node.

func (*Agent) NodeValidateImplementation

func (a *Agent) NodeValidateImplementation(node nodeTypes.Node) error

NodeValidateImplementation is called to validate the implementation of the node in the datapath. This function is intended to be run on an interval to ensure that the datapath is consistently converged.

func (*Agent) OnIPIdentityCacheChange

func (a *Agent) OnIPIdentityCacheChange(modType ipcache.CacheModification, cidrCluster cmtypes.PrefixCluster, oldHostIP, newHostIP net.IP,
	_ *ipcache.Identity, _ ipcache.Identity, _ uint8, _ *ipcache.K8sMetadata, _ uint8)

OnIPIdentityCacheChange implements ipcache.IPIdentityMappingListener

func (*Agent) Start added in v1.17.0

func (a *Agent) Start(cell.HookContext) error

Start implements cell.HookInterface.

func (*Agent) Status

func (a *Agent) Status(withPeers bool) (*models.WireguardStatus, error)

Status returns the state of the WireGuard tunnel managed by this instance. If withPeers is true, then the details about each connected peer are are populated as well.

func (*Agent) Stop added in v1.17.0

func (a *Agent) Stop(cell.HookContext) error

Stop implements cell.HookInterface.

type Config added in v1.19.0

type Config struct {
	UserConfig

	StateDir         string
	EnableIPv4       bool
	EnableIPv6       bool
	TunnelingEnabled bool
	EncryptNode      bool
}

Final config of the WireGuard agent.

func (Config) Enabled added in v1.19.0

func (c Config) Enabled() bool

Returns true when enabled. Implements types.WireguardConfig.

type UserConfig added in v1.19.0

type UserConfig struct {
	EnableWireguard              bool
	WireguardTrackAllIPsFallback bool
	WireguardPersistentKeepalive time.Duration
	NodeEncryptionOptOutLabels   string
}

User provided flags.

func (UserConfig) Flags added in v1.19.0

func (def UserConfig) Flags(flags *pflag.FlagSet)

Jump to

Keyboard shortcuts

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