voice

package
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package voice is the contract between the relay and gawk-mumble-bridge (R79, docs/80): the voice ticket the relay's home pod mints and the bridge verifies offline (D7), the fleet-stable temporary channel key (D11), and the two internal links that keep the relay the authority over voice (D2): the observer link (relay → bridge) and the session link (bridge → relay).

It is public — outside internal/ — for the reason wire and screening are: a second top-level module (gawk-mumble-bridge) compiles it in through its replace, and a hand-written second copy of the ticket or the link messages is exactly what drifts. A semantic change here needs a commit touching gawk-mumble-bridge/ in the same PR (CONTRIBUTING.md, the release-coupling rule).

Nothing here ever carries voice audio, and nothing here carries a publisher IP (D24). Room codes are raw: both links are internal, PSK-gated and never routed publicly; logs on either side key rooms by the keyed hash.

Index

Constants

View Source
const (
	// ObservePath is the bridge's internal route the relay dials.
	ObservePath = "/internal/observe"
	// SessionPath is the relay's route the bridge dials, + the room code.
	SessionPath = "/internal/voice/"
	// LinkOrigin is the Origin header both link dialers send; the relay
	// already accepts it on /internal/* (internalEdgeOrigin, restated here
	// because that constant is internal; the relay test pins the two equal).
	LinkOrigin = "gawk-server://native-internal-edge"
	// MaxMessageSize bounds one link message. A roster of a few hundred
	// users is well under it.
	MaxMessageSize = 256 << 10
)

The two internal links (docs/80 D2). Both are WebTransport sessions gated by -voice-bridge-psk (the `psk` query parameter, as on the relay's /internal/* routes), and on both the dialer opens ONE bidirectional stream and the two sides exchange Messages on it, each framed as uint32 length (big-endian) ‖ JSON. The session ending, from either side and for any reason, ends what the link stands for: the observer, or the browser's voice session.

Observer link — the room's HOME relay pod dials the bridge's internal listener, CONNECT ObservePath?psk=…, when a room becomes voice-live (D12), and redials with a backoff while it stays voice-live (D4). The bridge pod that accepts opens the room's observer Mumble connection.

relay  → bridge  Observe        first message: which room, which channel
bridge → relay   Roster         the channel's users, on every change;
                                Available false (with Reason) while the
                                observer cannot reach or enter the
                                channel

Session link — the bridge pod that accepted a browser's voice session dials the relay, CONNECT SessionPath + code + ?psk=…, through the relay's Service; a non-home relay pod proxies it to the home (as /internal/room).

bridge → relay   Register       first message: the browser's ticket and
                                its source address (for gawk IP bans,
                                D17 — the voice client's own address,
                                never a publisher's)
relay  → bridge  Accepted       the home took it; open the Mumble user
bridge → relay   Joined         the bridged user is in the channel
bridge → relay   State          its mute/deafen state changed
relay  → bridge  Close          end this voice session with Code
bridge → relay   Left           the Mumble side ended it (a kick, a ban,
                                murmur gone), with the code the browser
                                was closed with

A refused Register is a Close followed by the session close.

View Source
const (
	TypeObserve  = "observe"
	TypeRoster   = "roster"
	TypeRegister = "register"
	TypeAccepted = "accepted"
	TypeJoined   = "joined"
	TypeState    = "state"
	TypeClose    = "close"
	TypeLeft     = "left"
)

Message types.

View Source
const DefaultTempChannelTemplate = "gawk {key}"

DefaultTempChannelTemplate is -mumble-temp-channel-template's default (OD32): no room code.

View Source
const MinSecretLen = 16

MinSecretLen is the shortest -voice-ticket-secret either side accepts.

View Source
const NonceSize = 16

NonceSize is the byte length of a ticket nonce.

View Source
const TicketTTL = 30 * time.Second

TicketTTL is how long a ticket opens a voice session after minting (D7). The ticket only opens the session; the session link keeps it authorised.

Variables

View Source
var (
	// ErrBadTicket: malformed, wrong MAC, or not a ticket at all.
	ErrBadTicket = errors.New("voice: invalid ticket")
	// ErrTicketExpired: a well-formed ticket past its expiry.
	ErrTicketExpired = errors.New("voice: ticket expired")
)

Sentinel errors.

View Source
var ErrMessageTooLarge = errors.New("voice: link message too large")

ErrMessageTooLarge is returned for a frame longer than MaxMessageSize.

Functions

func ChannelKey

func ChannelKey(secret []byte, code string) string

ChannelKey is the fleet-stable handle a dynamic room's temporary Mumble channel is named by (D11): the first six characters of the standard base32 encoding of HMAC-SHA256(secret, "mumble-channel:" + code), over the normalized code (the relay sends it normalized). Every relay and bridge pod holds the secret, so the name is the same whichever pod runs the observer, and it reveals nothing about the code.

func ChannelPath

func ChannelPath(channel string) []string

ChannelPath splits a static room's `integrations.mumble.channel` into its path elements below the root ("Friends/Gaming" → [Friends Gaming]). Empty elements are dropped; an empty path is the root channel.

func MintTicket

func MintTicket(secret []byte, t Ticket) ([]byte, error)

MintTicket encodes and signs t.

func NewNonce

func NewNonce() ([NonceSize]byte, error)

NewNonce returns a fresh random nonce.

func TempChannelName

func TempChannelName(template string, secret []byte, code, displayCode string) string

TempChannelName expands an operator template: {key} is ChannelKey, {code} the room's display code (only when the operator asks for it).

func WriteMessage

func WriteMessage(w io.Writer, m Message) error

WriteMessage frames and writes one message.

Types

type Message

type Message struct {
	Type string `json:"type"`

	// Observe: the room (normalized code) and its mapping.
	Code string `json:"code,omitempty"`
	// DisplayCode is the code as shown, for a {code} temp-channel template.
	DisplayCode string `json:"displayCode,omitempty"`
	// Channel is a static room's channel path ("Friends/Gaming"); empty
	// with Temporary.
	Channel string `json:"channel,omitempty"`
	// Temporary asks for the dynamic room's temporary channel (D11).
	Temporary bool `json:"temporary,omitempty"`
	// Epoch is the home's epoch for the room (the ticket's, D7). Carried
	// on Observe so a bridge can log a home move; never trusted for auth.
	Epoch uint64 `json:"epoch,omitempty"`

	// Roster: the channel's users and whether the observer is in it.
	Available bool     `json:"available,omitempty"`
	Users     []User   `json:"users,omitempty"`
	Reason    string   `json:"reason,omitempty"`
	Problems  []string `json:"problems,omitempty"`

	// Register: the raw ticket and the voice client's address.
	Ticket []byte `json:"ticket,omitempty"`
	Remote string `json:"remote,omitempty"`

	// Joined / State: the bridged user's Mumble session, name and state.
	Session uint32 `json:"session,omitempty"`
	Name    string `json:"name,omitempty"`
	Flags   uint8  `json:"flags,omitempty"`

	// Close / Left: the close code (4015, 4016, 4002) and its reason.
	CloseCode uint32 `json:"closeCode,omitempty"`
}

Message is one link message. Type says which fields are meaningful.

func ReadMessage

func ReadMessage(r io.Reader) (Message, error)

ReadMessage reads one framed message. The length is validated before any allocation.

type Ticket

type Ticket struct {
	Code        string
	Participant uint16
	Nickname    string
	Nonce       [NonceSize]byte
	Epoch       uint64
	Expiry      time.Time
}

Ticket is what the room's home pod vouches for when it answers a VoiceJoin (D7). Layout, big-endian:

byte 0     version (1)
uint8      codeLen, then the normalized room code
uint16     participant ID
uint8      nickLen, then the gawk nickname (UTF-8, ≤ wire.MaxRoomNicknameLen)
16 bytes   nonce
uint64     epoch: the minting home's room lease generation in cluster
           mode, a random per-process value on a single pod
int64      expiry, Unix milliseconds
32 bytes   HMAC-SHA256(secret, ticketDomain ‖ all preceding bytes)

func VerifyTicket

func VerifyTicket(secret, raw []byte, now time.Time) (Ticket, error)

VerifyTicket checks raw's MAC under secret and its expiry against now. ErrBadTicket for anything malformed or forged, ErrTicketExpired for a genuine ticket past its expiry. Single use is NOT checked here: the home pod checks the nonce at registration (D5).

type User

type User struct {
	Session uint32 `json:"session"`
	Name    string `json:"name"`
	// Flags is the wire.RoomVoiceUser* bitmap.
	Flags uint8 `json:"flags,omitempty"`
}

User is one Mumble user in a room's channel as the observer sees it.

Jump to

Keyboard shortcuts

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