peerexchange

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package peerexchange orchestrates peer endpoint exchange for plexd mesh nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	nat.Config
}

Config holds the configuration for peer endpoint exchange. It embeds nat.Config to reuse NAT traversal settings.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults sets default values for zero-valued fields.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that configuration values are within acceptable ranges.

type Exchanger

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

Exchanger orchestrates peer endpoint exchange: STUN discovery, control plane reporting, and WireGuard peer endpoint updates.

func NewExchanger

func NewExchanger(discoverer *nat.Discoverer, wgManager *wireguard.Manager, cpClient *api.ControlPlane, cfg Config, logger *slog.Logger) *Exchanger

NewExchanger creates a new Exchanger.

func (*Exchanger) LastResult

func (e *Exchanger) LastResult() *api.NATInfo

LastResult returns the most recently discovered NAT info.

func (*Exchanger) RegisterHandlers

func (e *Exchanger) RegisterHandlers(sseManager *api.SSEManager)

RegisterHandlers registers SSE event handlers for peer endpoint changes. Must be called before the SSEManager is started. Handlers are registered regardless of whether NAT is enabled, because inbound peer endpoint updates must still be processed.

func (*Exchanger) Run

func (e *Exchanger) Run(ctx context.Context, nodeID string) error

Run starts the endpoint exchange loop. If NAT is disabled, it returns nil immediately. Otherwise, it delegates to nat.Discoverer.Run. It blocks until ctx is cancelled.

Jump to

Keyboard shortcuts

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