netstack

package
v0.0.0-...-0721423 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MemoryPipe

func MemoryPipe(c1, c2 *channel.Endpoint)

MemoryPipe is used to join two endpoints together, allowing them to communicate.

Types

type Endpoint

type Endpoint struct {
	*channel.Endpoint
	Logger *zap.Logger
}

Endpoint is a wrapper around a channel.Endpoint that implements the io.Reader and io.Writer interfaces.

func WrapChannel

func WrapChannel(channel *channel.Endpoint) *Endpoint

WrapChannel wraps the provided netstack channel-based Endpoint and returns a wrapper that implements io.Reader and io.Writer on the channel. This allows callers to read and write packets as raw []byte directly to the channel.

func (*Endpoint) Read

func (e *Endpoint) Read(p []byte) (n int, err error)

func (*Endpoint) Write

func (e *Endpoint) Write(p []byte) (n int, err error)

type HTTPOverTCPForwarder

type HTTPOverTCPForwarder struct {
	Server http.Server
	Logger *zap.Logger
}

HTTPOverTCPForwarder is a proof-of-concept for a TCP forwarder that only handles HTTP requests and forwards them to a local HTTP server.

func (*HTTPOverTCPForwarder) Handle

type TCPForwarder

type TCPForwarder struct {
	Logger *zap.Logger
}

TCPForwarder knows how to forward TCP traffic from the userspace network Stack to the host's network Stack. TCP dialing requests from the userspace network Stack are done by the host's network Stack which allows userspace traffic to exit the userspace Stack.

func (*TCPForwarder) Handle

func (f *TCPForwarder) Handle(r *tcp.ForwarderRequest)

type TestStack

type TestStack struct {
	Stack    *stack.Stack
	Endpoint *channel.Endpoint
	// contains filtered or unexported fields
}

func NewTestStack

func NewTestStack(logger *zap.Logger, nic string, routes []string, forwarding bool) (*TestStack, error)

NewTestStack creates a new netstack for testing with a single nic, and with the provided routes. The routes are expected to be CIDR blocks that this Stack is allowed to route to.

type UDPForwarder

type UDPForwarder struct {
	Logger  *zap.Logger
	Stack   *stack.Stack
	Timeout time.Duration
	MTU     int
}

UDPForwarder knows how to forward UDP traffic from the userspace network Stack through the host networking Stack.

func (*UDPForwarder) Handle

func (u *UDPForwarder) Handle(r *udp.ForwarderRequest)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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