package relayproto
Import Path
github.com/tmc/go-iroh/internal/relayproto (on go.dev)
Dependency Relation
imports 10 packages, and imported by 2 packages
Involved Source Files
datagrams.go
Package relayproto implements the iroh relay wire protocol: the framing,
datagram, and handshake messages exchanged between a relay client and server.
It is a port of iroh-relay/src/protos. Frames are carried in binary WebSocket
messages; each frame begins with a QUIC-varint frame type followed by a
type-specific payload. The encodings here are byte-for-byte compatible with
the Rust reference (verified by golden snapshot tests).
handshake.go
messages.go
varint.go
Package-Level Type Names (total 12)
ClientAuth is the client's authentication response: its public key and a
signature of the challenge's message-to-sign.
PublicKey key.PublicKey
Signature key.Signature
AppendTo appends the framed wire encoding of a: frame type, the public key's
32 raw bytes, then the signature as a postcard serde_bytes value (varint
length 64 followed by the 64 bytes).
Verify checks this client auth against the challenge it answers.
func NewClientAuth(secretKey key.SecretKey, challenge ServerChallenge) ClientAuth
ClientToRelayMsg is a message a client sends to a relay. Exactly one of its
fields is meaningful, selected by Type.
Datagrams Datagrams
DstEndpointID / Datagrams for FrameClientToRelayDatagram(Batch).
Ping/Pong payload for FramePing/FramePong.
Type FrameType
AppendTo appends the wire encoding of m to dst.
EncodedLen returns the number of bytes AppendTo writes.
func ParseClientToRelayMsg(content []byte) (ClientToRelayMsg, error)
func ParseClientToRelayMsgNoCopy(content []byte) (ClientToRelayMsg, error)
func github.com/tmc/go-iroh/internal/relayclient.(*Client).Send(ctx context.Context, msg ClientToRelayMsg) error
Datagrams is one or multiple datagrams transferred via the relay, modeled
after the QUIC transmit structure.
Contents holds the datagram bytes.
Ecn is the explicit congestion notification codepoint, or 0 for Not-ECT.
SegmentSize is the per-datagram segment size when this transmit carries
multiple datagrams (a batch); 0 means a single datagram.
func DatagramsFromBytes(b []byte) Datagrams
EcnCodepoint is the QUIC explicit-congestion-notification codepoint carried in
a relayed datagram (RFC 9000 ยง13.4 / IP ECN field values).
const EcnCe
const EcnEct0
const EcnEct1
FrameType identifies a relay protocol frame. It is encoded on the wire as a
QUIC varint.
( FrameType) String() string
FrameType : expvar.Var
FrameType : fmt.Stringer
const FrameClientAuth
const FrameClientToRelayDatagram
const FrameClientToRelayDatagramBat
const FrameEndpointGone
const FrameHealth
const FramePing
const FramePong
const FrameRelayToClientDatagram
const FrameRelayToClientDatagramBat
const FrameRestarting
const FrameServerChallenge
const FrameServerConfirmsAuth
const FrameServerDeniesAuth
const FrameStatus
KeyMaterialClientAuth is the client's 1-RTT relay authentication. It is sent
in [ClientAuthHeader] as base64url-no-pad postcard bytes.
KeyMaterialSuffix [16]byte
PublicKey key.PublicKey
Signature key.Signature
DecodePostcard decodes a Rust KeyMaterialClientAuth.
EncodePostcard encodes a like Rust KeyMaterialClientAuth: raw public key,
serde_bytes signature, then raw 16-byte suffix.
HeaderValue encodes a for [ClientAuthHeader].
Verify checks this key-material auth against the server's TLS state.
*KeyMaterialClientAuth : github.com/tmc/go-iroh/internal/postcard.DecoderFrom
KeyMaterialClientAuth : github.com/tmc/go-iroh/internal/postcard.EncoderTo
func KeyMaterialClientAuthFromHeader(value string) (KeyMaterialClientAuth, error)
func NewKeyMaterialClientAuth(secretKey key.SecretKey, state *tls.ConnectionState) (KeyMaterialClientAuth, error)
ProtocolVersion is the negotiated relay protocol version for a connection.
WireString returns the wire identifier for v.
func ParseProtocolVersion(s string) (ProtocolVersion, bool)
func github.com/tmc/go-iroh/internal/relayclient.(*Client).Version() ProtocolVersion
func ParseRelayToClientMsg(content []byte, version ProtocolVersion) (RelayToClientMsg, error)
func ParseRelayToClientMsgNoCopy(content []byte, version ProtocolVersion) (RelayToClientMsg, error)
const ProtocolV1
const ProtocolV2
RelayToClientMsg is a message a relay sends to a client. Exactly one of its
fields is meaningful, selected by Type.
Datagrams Datagrams
EndpointGone for FrameEndpointGone.
Health problem text for FrameHealth (deprecated, V1 only).
Ping/Pong payload for FramePing/FramePong.
Restarting durations for FrameRestarting.
Datagrams / RemoteEndpointID for FrameRelayToClientDatagram(Batch).
Status for FrameStatus.
TryFor time.Duration
Type FrameType
AppendTo appends the wire encoding of m to dst.
EncodedLen returns the number of bytes AppendTo writes.
func ParseRelayToClientMsg(content []byte, version ProtocolVersion) (RelayToClientMsg, error)
func ParseRelayToClientMsgNoCopy(content []byte, version ProtocolVersion) (RelayToClientMsg, error)
func github.com/tmc/go-iroh/internal/relayclient.(*Client).Recv(ctx context.Context) (RelayToClientMsg, error)
ServerChallenge is the challenge a relay sends a client to sign for endpoint
authentication.
Challenge is 16 random bytes the client must sign.
AppendTo appends the framed wire encoding (frame type + postcard body) of c.
func NewClientAuth(secretKey key.SecretKey, challenge ServerChallenge) ClientAuth
func ClientAuth.Verify(challenge ServerChallenge) error
ServerConfirmsAuth confirms a successful connection. Its postcard body is empty.
AppendTo appends the framed wire encoding of the (empty-bodied) confirmation.
ServerDeniesAuth denies a connection with a reason.
Reason string
AppendTo appends the framed wire encoding: frame type then the reason as a
postcard string (varint byte-length prefix + UTF-8 bytes).
Status is a one-way relay-to-client message declaring the connection health.
const StatusHealthy
const StatusRateLimited
const StatusSameEndpointIDConnected
Package-Level Functions (total 11)
DatagramsFromBytes wraps b as a single (non-batch) datagram.
KeyMaterialClientAuthFromHeader decodes a value from [ClientAuthHeader].
NewClientAuth builds a ClientAuth for challenge using secretKey.
NewKeyMaterialClientAuth builds a client auth header value from exported TLS
keying material. It returns [ErrNoKeyingMaterial] if state cannot export it.
ParseClientToRelayMsg decodes a client-to-relay message.
ParseClientToRelayMsgNoCopy decodes a client-to-relay message without
copying datagram contents. The returned message aliases content.
ParseHandshakeFrame parses one handshake frame from content (frame type +
postcard body) into the concrete frame value, returning the value as one of
*ServerChallenge, *ClientAuth, *ServerConfirmsAuth, or *ServerDeniesAuth.
ParseProtocolVersion parses a protocol version from its wire identifier.
ParseRelayToClientMsg decodes a relay-to-client message. version gates the
deprecated Health (V1 only) and Status (V2+) frames.
ParseRelayToClientMsgNoCopy decodes a relay-to-client message without
copying datagram contents. The returned message aliases content.
SupportedProtocolVersions returns the wire identifiers of all supported
protocol versions, newest first (the order offered to a relay server).
Package-Level Variables (total 11)
Protocol errors.
Protocol errors.
Protocol errors.
Handshake errors.
Protocol errors.
Handshake errors.
Handshake errors.
Handshake errors.
Handshake errors.
Handshake errors.
Protocol errors.
Package-Level Constants (total 25)
ClientAuthHeader is the HTTP header carrying TLS key-material relay auth.
EcnCe is CE (congestion experienced).
EcnEct0 is ECT(0).
EcnEct1 is ECT(1).
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
Frame types, matching iroh-relay/src/protos/common.rs.
MaxPacketSize is the maximum size of a packet sent over the relay, counting
only the visible data bytes, not the on-wire framing overhead.
PerClientSendQueueDepth is the number of packets buffered for sending per
client by a relay server.
Relay protocol versions.
Relay protocol versions.
StatusHealthy reports the connection recovered from previous problems.
StatusRateLimited reports the relay is throttling this client's
outbound traffic.
StatusSameEndpointIDConnected reports another endpoint connected with the
same id; no more messages will be received.
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |