gvisorgvisor.dev/gvisor/runsc/boot/portforward Index | Files

package portforward

import "gvisor.dev/gvisor/runsc/boot/portforward"

Package portforward holds the infrastructure to support the port forward command.

Index

Functions

func NewFileDescriptionConn

func NewFileDescriptionConn(file *vfs.FileDescription) proxyConn

NewFileDescriptionConn initializes a fileDescriptionConn.

func NewHostInetConn

func NewHostInetConn(port uint16) (proxyConn, error)

NewHostInetConn creates a hostInetConn backed by a host socket on the localhost address.

func NewNetstackConn

func NewNetstackConn(stack *stack.Stack, port uint16) (proxyConn, error)

NewNetstackConn creates a new port forwarding connection to the given port in netstack mode.

Types

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy controls copying data between two proxyConnections. Proxy takes ownership over the two connections and is responsible for cleaning up their resources (i.e. calling their Close method). Proxy(s) all run internal to the sandbox on the supervisor context.

func NewProxy

func NewProxy(pair ProxyPair, cid string) *Proxy

NewProxy returns a new Proxy.

func (*Proxy) AddCleanup

func (pf *Proxy) AddCleanup(cu func())

AddCleanup adds a cleanup to this Proxy's cleanup.

func (*Proxy) Close

func (pf *Proxy) Close()

Close cleans up the resources in this Proxy and blocks until all resources are cleaned up and their goroutines exit.

func (*Proxy) Start

func (pf *Proxy) Start(ctx context.Context)

Start starts the proxy. On error on either end, the proxy cleans itself up by stopping both connections.

type ProxyPair

type ProxyPair struct {
	To   proxyConn
	From proxyConn
}

ProxyPair wraps the to/from arguments for NewProxy so that the user explicitly labels to/from.

Source Files

portforward.go portforward_fd_rw.go portforward_hostinet.go portforward_netstack.go portforward_test_util.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
18 packages
Last checked
5 hours ago

Tools for package owners.