wan

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package wan provides a WAN Bridge that forwards DDS samples between two Participant domains over a TCP connection (Milestone 10 — Routing: WAN bridge).

A server Bridge receives frames from connected clients and publishes the samples to a local Participant. A client Bridge subscribes to configured DDS topics on a local Participant and streams the received samples to a server.

Wire format: each frame is a 4-byte big-endian length prefix followed by a JSON object {"t":"<topic>","p":"<base64-payload>"}. The 16 MiB frame cap prevents unbounded buffer allocation on malformed or malicious input.

For bidirectional bridging, create one server/client pair in each direction.

Index

Constants

This section is empty.

Variables

View Source
var ErrFrameTooLarge = errors.New("wan: frame too large")

ErrFrameTooLarge is returned by a server when an incoming frame exceeds the 16 MiB limit.

Functions

This section is empty.

Types

type Bridge

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

Bridge is a WAN bridge (server or client side). Create a server Bridge with Serve and a client Bridge with Connect.

Bridge is safe for concurrent use from multiple goroutines.

func Connect

func Connect(p dds.Participant, addr string, opts Options) (*Bridge, error)

Connect creates a WAN bridge client that connects to addr. Topic subscriptions are created synchronously before Connect returns, so no samples published after Connect returns are missed.

Returns an error if any topic subscription fails (e.g. p is already closed) or if the TCP connection cannot be established.

func Serve

func Serve(p dds.Participant, addr string, opts Options) (*Bridge, error)

Serve creates a WAN bridge server that listens on addr. Samples received from connected clients are published to p. Use Bridge.Addr to discover the actual bound address when addr uses port 0.

func (*Bridge) Addr

func (b *Bridge) Addr() string

Addr returns the TCP address the server Bridge is listening on. Returns an empty string for client Bridges created by Connect.

func (*Bridge) Close

func (b *Bridge) Close() error

Close stops the bridge and waits for all goroutines to exit. Safe to call multiple times.

type Options

type Options struct {
	// Topics lists the DDS topic names to forward.
	// Only used by client Bridges ([Connect]); server Bridges publish any topic
	// they receive and do not filter.
	Topics []string
	// QoS is applied to all bridged DDS endpoints. Zero value uses dds.DefaultQoS.
	QoS dds.QoS
}

Options configures a WAN Bridge.

Jump to

Keyboard shortcuts

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