net

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataChannelOptions added in v0.4.0

type DataChannelOptions struct {
	// RendevousStrings is a map of peer IDs to rendezvous strings
	// where peers are accepting signaling via libp2p.
	RendezvousStrings map[string]string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// LocalAddrs is a list of local addresses to announce the host with.
	// If empty or nil, the default local addresses will be used.
	LocalAddrs []multiaddr.Multiaddr
	// ConnectTimeout is the timeout to use when connecting to peers.
	ConnectTimeout time.Duration
}

DataChannelOptions are options for when presented with the need to negotiate p2p wireguard connections. Empty values mean to use the defaults.

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 against the provided list and makes sure
	// they are up to date.
	RefreshPeers(ctx context.Context, peers []*v1.WireGuardPeer) 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
	// Dial behaves like the standard library DialContext, but uses the
	// wireguard interface for all connections. The address can be a nodeID
	// or a network address.
	Dial(ctx context.Context, network, address string) (net.Conn, error)
	// 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
	// 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
	// LocalDNSAddr is a local network address service MeshDNS.
	LocalDNSAddr netip.AddrPort
	// DisableIPv4 disables IPv4 on the interface.
	DisableIPv4 bool
	// DisableIPv6 disables IPv6 on the interface.
	DisableIPv6 bool
	// DataChannels are options for when presented with the need to negotiate
	// p2p data channels.
	DataChannels DataChannelOptions
}

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 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 defines the interfaces needed for various mesh operations.
Package transport defines the interfaces needed for various mesh operations.
datachannels
Package datachannels provides a WebRTC data channel API for port forwarding.
Package datachannels provides a WebRTC data channel API for port forwarding.
libp2p
Package libp2p provides discovery mechanisms using Kademlia DHT.
Package libp2p provides discovery mechanisms using Kademlia DHT.
tcp
Package tcp provides TCP based transports.
Package tcp provides TCP based transports.
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