networking

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: AGPL-3.0 Imports: 5 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

This section is empty.

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 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