networking

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package networking provides abstraction layers for accessing networking resources both across platform specific details, and for virtual / mock configurations for testing

Index

Constants

This section is empty.

Variables

View Source
var ErrAddAddrUnsupported = errors.New("this platform doesn't support interface configuration yet")

ErrAddAddrUnsupported is returned from Interface.AddAddr on platforms where a network interface configuration API is not yet supported

Functions

This section is empty.

Types

type Environment

type Environment interface {
	io.Closer
	// Interfaces is typically a wrapper for net.Interfaces()
	Interfaces() ([]Interface, error)
	// InterfaceByName looks up an interface by its name
	InterfaceByName(string) (Interface, error)

	// ListenUDP abstracts net.ListenUDP
	ListenUDP(network string, laddr *net.UDPAddr) (UDPConn, error)

	// NewWgClient creates a wireguard client interface for the host
	NewWgClient() (internal.WgClient, error)
}

Environment represents the top level abstraction of the system's networking environment.

type Interface

type Interface interface {
	Name() string
	IsUp() bool
	Addrs() ([]net.IPNet, error)
	AddAddr(net.IPNet) error
}

Interface represents a single network interface

type UDPConn added in v0.9.1

type UDPConn interface {
	io.Closer

	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error

	ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error)
	WriteToUDP(p []byte, addr *net.UDPAddr) (n int, err error)

	// ReadPackets reads packets from the connection until it is either closed,
	// or the passed context is cancelled.
	// Packets or errors (other than the connection being closed) will be sent
	// to the output channel, which will be closed when this routine finishes.
	// Closing the connection is always the responsibility of the caller.
	ReadPackets(
		ctx context.Context,
		maxSize int,
		output chan<- *UDPPacket,
	) error
}

UDPConn abstracts net.UDPConn

type UDPPacket added in v0.9.1

type UDPPacket struct {
	Time time.Time
	Data []byte
	Addr *net.UDPAddr
	Err  error
}

UDPPacket represents a single result from ReadFromUDP, wrapped in a struct so that it can be sent on a channel.

Directories

Path Synopsis
Package darwin provides an implementation of networking.Environment for the host darwin (macOS) system, leveraging the Go native package, and then filling in the gaps by exececuting command line tools such as ifconfig.
Package darwin provides an implementation of networking.Environment for the host darwin (macOS) system, leveraging the Go native package, and then filling in the gaps by exececuting command line tools such as ifconfig.
Package host provides a generic accessor factory to create the appropriate platform-specific interface to the host networking APIs.
Package host provides a generic accessor factory to create the appropriate platform-specific interface to the host networking APIs.
Package linux provides an implementation of networking.Environment for the host Linux system, leveraging the Go native package, and then filling in the gaps using netlink APIs.
Package linux provides an implementation of networking.Environment for the host Linux system, leveraging the Go native package, and then filling in the gaps using netlink APIs.
Package mocks provides mock implementations of the networking apis, for the testify mock library, generated via go generate and mockery.
Package mocks provides mock implementations of the networking apis, for the testify mock library, generated via go generate and mockery.
Package native provdies common base implementations of the networking.Environment and related interfaces, or at least the portions that can be implemented using common native Go APIs.
Package native provdies common base implementations of the networking.Environment and related interfaces, or at least the portions that can be implemented using common native Go APIs.
Package vnet provides a virtual (as opposed to mocked) implementation of the abstracted UDP networking stack.
Package vnet provides a virtual (as opposed to mocked) implementation of the abstracted UDP networking stack.

Jump to

Keyboard shortcuts

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