stream_datagram

package
v0.57.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package stream_datagram forwards UDP packets over an established peer stream. Each stream has one fixed UDP peer and one socket; peer authentication and stream admission belong to the caller's existing link/session authority.

Index

Constants

View Source
const MaxPacketSize = 65507

MaxPacketSize bounds packets to the maximum IPv4 UDP payload. The wire format is a two-byte big-endian payload length followed by exactly that many bytes. Empty datagrams are preserved. A reliable stream retains ordering and can introduce head-of-line blocking; this adapter does not change that transport.

Variables

This section is empty.

Functions

func Forward

func Forward(ctx context.Context, socket *net.UDPConn, peer *net.UDPAddr, peerStream io.ReadWriteCloser) error

Forward owns socket and peerStream until it returns, including on failure. socket must be unconnected and peer is the only permitted UDP sender and destination. Other local senders are ignored. Cancellation or either side failing closes both resources and waits for both forwarding pumps to finish. The caller binds a fresh socket per player/session; never share this socket with another Forward call. Only admitted sessions should reach this API.

func ForwardLocal

func ForwardLocal(ctx context.Context, socket *net.UDPConn, peerStream io.ReadWriteCloser) error

ForwardLocal forwards one local application's UDP association. socket must be bound to loopback. Its first sender becomes the fixed peer for this stream; packets from other senders are ignored. The first packet is retained and forwarded. The caller owns admission of the remote stream and gives only its selected local application this endpoint. Cancellation closes both resources.

func ForwardTarget

func ForwardTarget(ctx context.Context, target *net.UDPAddr, peerStream io.ReadWriteCloser) error

ForwardTarget allocates a dedicated upstream UDP association for one peer stream, then forwards to a fixed service endpoint. Separate calls produce separate source ports at the service, so replies cannot cross player streams. It owns peerStream even if binding the socket fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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