net

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 23 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
	// NetworkV4 returns the current IPv4 network. The returned value may be invalid.
	NetworkV4() netip.Prefix
	// NetworkV6 returns the current IPv6 network, even if it is disabled.
	NetworkV6() netip.Prefix
	// StartMasquerade ensures that masquerading is enabled.
	StartMasquerade(ctx context.Context) error
	// AddDNSServers adds the given dns servers to the system configuration.
	AddDNSServers(ctx context.Context, servers []netip.AddrPort) error
	// RefreshDNSServers checks which peers in the database are offering DNS
	// and updates the system configuration accordingly.
	RefreshDNSServers(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
	// Resolver returns a net.Resolver that can be used to resolve DNS names.
	Resolver() *net.Resolver
	// 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 storage.MeshStorage, opts *Options) Manager

New creates a new network manager.

type Options

type Options struct {
	// NodeID is the ID of the node.
	NodeID string
	// 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
	// DisableIPv4 disables IPv4 on the interface.
	DisableIPv4 bool
	// DisableIPv6 disables IPv6 on the interface.
	DisableIPv6 bool
}

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 mesh contains helpers for computing networking information from the mesh.
Package mesh contains helpers for computing networking information from the mesh.
Package nat64 provides a stateless bi-directional NAT64 implementation.
Package nat64 provides a stateless bi-directional NAT64 implementation.
Package system contains utilities for managing network interfaces on the system.
Package system contains utilities for managing network interfaces on the system.
buffers
Package buffers contains facilities for changing system buffer sizes.
Package buffers contains facilities for changing system buffer sizes.
dns
Package dns contains utility functions for DNS.
Package dns contains utility functions for DNS.
firewall
Package firewall contains an interface for interacting with the system firewall.
Package firewall contains an interface for interacting with the system firewall.
Package transport provides a simple interface for sending and receiving raft messages between nodes.
Package transport provides a simple interface for sending and receiving raft messages between nodes.
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