net

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// Start starts the network manager.
	Start(ctx context.Context, opts *StartOptions) error
	// StartMasquerade ensures that masquerading is enabled.
	StartMasquerade(ctx context.Context) error
	// AddPeer adds a peer to the wireguard interface.
	AddPeer(ctx context.Context, peer *v1.WireGuardPeer, iceServers []string) error
	// RefreshPeers walks all peers in the database and ensures they are added to the wireguard interface.
	RefreshPeers(ctx context.Context) error
	// Firewall returns the firewall.
	// The firewall is only available after Start has been called.
	Firewall() firewall.Firewall
	// WireGuard returns the wireguard interface.
	// The wireguard interface is only available after Start has been called.
	WireGuard() wireguard.Interface
	// Close closes the network manager and cleans up any resources.
	Close(ctx context.Context) error
}

Manager is the interface for managing the network.

func New

func New(store meshdb.Store, opts *Options) Manager

New creates a new network manager.

type Options

type Options struct {
	// InterfaceName is the name of the wireguard interface.
	InterfaceName string
	// ForceReplace is whether to force replace the wireguard interface.
	ForceReplace bool
	// ListenPort is the port to use for wireguard.
	ListenPort int
	// PersistentKeepAlive is the persistent keepalive to use for wireguard.
	PersistentKeepAlive time.Duration
	// ForceTUN is whether to force the use of TUN.
	ForceTUN bool
	// Modprobe is whether to use modprobe to attempt to load the wireguard kernel module.
	Modprobe bool
	// MTU is the MTU to use for the wireguard interface.
	MTU int
	// RecordMetrics is whether to enable metrics recording.
	RecordMetrics bool
	// RecordMetricsInterval is the interval to use for recording metrics.
	RecordMetricsInterval time.Duration
	// RaftPort is the port being used for raft.
	RaftPort int
	// GRPCPort is the port being used for gRPC.
	GRPCPort int
	// ZoneAwarenessID is the zone awareness ID.
	ZoneAwarenessID string
	// DialOptions are the dial options to use when calling peer nodes.
	DialOptions []grpc.DialOption
}

Options are the options for the network manager.

type StartOptions

type StartOptions struct {
	// Key is the wireguard key to use for the node.
	Key wgtypes.Key
	// AddressV4 is the IPv4 address to use for the node.
	AddressV4 netip.Prefix
	// AddressV6 is the IPv6 address to use for the node.
	AddressV6 netip.Prefix
	// NetworkV4 is the IPv4 network to use for the node.
	NetworkV4 netip.Prefix
	// NetworkV6 is the IPv6 network to use for the node.
	NetworkV6 netip.Prefix
}

StartOptions are the options for starting the network manager and configuring the wireguard interface.

Directories

Path Synopsis
Package datachannels provides a WebRTC data channel API for port forwarding.
Package datachannels provides a WebRTC data channel API for port forwarding.
Package inspect contains facilities for tapping into the network stack.
Package inspect contains facilities for tapping into the network stack.
Package mesh contains helpers for computing networking information from the mesh.
Package mesh contains helpers for computing networking information from the mesh.
Package system contains utilities for managing network interfaces on the system.
Package system contains utilities for managing network interfaces on the system.
firewall
Package firewall contains an interface for interacting with the system firewall.
Package firewall contains an interface for interacting with the system firewall.
Package wireguard contains utilities for working with wireguard interfaces.
Package wireguard contains utilities for working with wireguard interfaces.

Jump to

Keyboard shortcuts

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