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 ¶
var ErrFrameTooLarge = errors.New("wan: frame too large")
ErrFrameTooLarge is returned by a server when an incoming frame exceeds the 16 MiB limit.
ErrUnauthorized is returned (server side) when a client's auth token does not match the configured token.
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 ¶
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 ¶
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.
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
// TLS, when non-nil, encrypts the bridge connection. A server ([Serve]) uses
// it as its server config (must carry a certificate); a client ([Connect])
// uses it to dial (set RootCAs / ServerName, or use mTLS via Certificates).
// Nil leaves the connection as plain TCP (backward-compatible).
TLS *tls.Config
// Token, when non-empty, enables shared-secret authentication. The client
// sends it as the first frame on connect; the server rejects any client
// whose token does not match (constant-time compare). Empty disables auth.
// For real deployments use Token together with TLS so the token is not sent
// in clear text.
Token string
}
Options configures a WAN Bridge.