socketforward

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStreamID

func GenerateStreamID(prefix string) (string, error)

GenerateStreamID creates a pseudo-random stream ID with the given prefix. The format is "{prefix}-{nanosecond}-{random}" to minimize collisions.

Types

type Service

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

Service implements the VM-side socket forwarding ttrpc service. The VM creates UNIX listener sockets inside the VM and notifies the host when a container process connects, so the host can open a vsock stream and relay data to the target host-side socket.

func NewService

func NewService(streams stream.Manager) *Service

NewService creates a new socket forwarding service.

func (*Service) Accept

Accept is a bidirectional streaming RPC used to coordinate forwarded connections. The VM sends a ConnectRequest when a container process connects to a forwarded socket; the host resolves the forward_id, dials the target host socket, opens a vsock stream, and sends back a ConnectResult reporting success or failure. On failure the VM closes the pending container connection immediately.

func (*Service) Bind

Bind sets up socket forward entries on the VM side. For each entry it creates a UNIX listener socket at the given socket_path. This method returns only after all socket files have been created.

func (*Service) RegisterTTRPC

func (s *Service) RegisterTTRPC(server *ttrpc.Server) error

RegisterTTRPC registers the socket forwarding service with the ttrpc server.

func (*Service) Shutdown

func (s *Service) Shutdown(_ context.Context) error

Shutdown closes all active listeners.

Jump to

Keyboard shortcuts

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