rooms

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 9 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 rooms holds the Room custom resource types and the room-code rules shared by the relay and gawk-admin (R42, docs/44 §4.3, RM1).

It is public — outside internal/ — for the same reason moderation is (docs/42 D13): gawk-admin compiles it in through its repo-root replace and must never mirror it. Keep it dependency-light: apimachinery only, no client-go, no hub types. Everything that needs a QUIC session or a hub registry lives in internal/roomsrv.

Index

Constants

View Source
const (
	GroupName = "gawk.ioio.fi"
	Version   = "v1alpha1"
	Kind      = "Room"
	ListKind  = "RoomList"
	// Resource is the plural lowercase resource name — what an informer
	// watches and what `kubectl get rooms` resolves to.
	Resource = "rooms"
)

The Room CRD's group/version/kind (docs/44 §4.3). Namespaced: rooms live beside the relay pods that home them, like Bans and origin Leases.

View Source
const (
	KindStatic  = "static"
	KindDynamic = "dynamic"
)

Room kinds (docs/44 D2).

View Source
const (
	MinCodeLen = 3
	MaxCodeLen = 32
)

Code limits (docs/44 §4.1): a static slug is 3–32 characters of [A-Za-z0-9-], case-insensitive, stored lower-case. A dynamic code is exactly broadcastid.Length characters of the broadcast alphabet and is stored lower-cased under the same rule, so one normalizer serves both.

View Source
const FingerprintSize = 8

FingerprintSize is the byte length of a creator-token fingerprint: the first 8 bytes of SHA-256(token), hex-encoded (docs/44 §4.3). The CR stores the fingerprint only, never the token.

View Source
const ScreeningExempt = "exempt"

ScreeningExempt is the one non-empty RoomSpec.Screening value.

Variables

View Source
var (
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
	AddToScheme   = SchemeBuilder.AddToScheme
)

SchemeBuilder / AddToScheme follow the client-go convention so both the relay's informer and gawk-admin's client can register the types.

View Source
var ErrInvalidCode = errors.New("rooms: invalid room code")

ErrInvalidCode is returned (possibly wrapped) for a code that fails the slug rules.

View Source
var ErrScreeningNotAllowed = errors.New("rooms: only a static room with an attach secret can be exempt from screening")

ErrScreeningNotAllowed is returned (wrapped) for an exemption the room's shape does not allow.

View Source
var GroupVersionResource = SchemeGroupVersion.WithResource(Resource)

GroupVersionResource addresses Rooms through a dynamic client.

View Source
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

SchemeGroupVersion is the group/version this package registers.

Functions

func DisplayCode

func DisplayCode(r *Room) string

DisplayCode returns the code as shown to people: a dynamic code in the broadcast alphabet's upper case, a static slug as configured (or, when the CR carries no displayCode, the normalized form).

func Fingerprint

func Fingerprint(token []byte) string

Fingerprint returns the stored fingerprint of a creator token.

func IsDynamicShape

func IsDynamicShape(code string) bool

IsDynamicShape reports whether a normalized code has the shape of a dynamic room code (and therefore of a broadcast ID): exactly broadcastid.Length characters of the broadcast alphabet. Only codes of this shape can be typed into the join box (docs/44 §4.2); a static slug that happens to have it is fine — the registry resolves by name and the CR spec says which kind it is.

func NormalizeCode

func NormalizeCode(s string) (string, error)

NormalizeCode lower-cases a room code and validates it against the slug rules. The result is both the CR name (`metadata.name`, which must be a DNS-1123 label: lower-case alphanumerics and '-', not starting or ending with '-') and the registry key. A dynamic six-character code passes unchanged in shape; use IsDynamicShape to tell the two apart when a typed code has to be resolved (docs/44 §4.2).

func ValidateScreening added in v0.33.0

func ValidateScreening(spec RoomSpec) error

ValidateScreening checks spec.Screening against the room's shape (docs/71 D11): empty is always valid, ScreeningExempt only on a static room whose attach secret makes "my friends' room" a trust boundary — an open or dynamic room could be joined by anyone, so exempting it would hand an abuser an unscreened lane. Anything else is an unknown value.

Types

type Attachment

type Attachment struct {
	BroadcastID string       `json:"broadcastID"`
	Label       string       `json:"label,omitempty"`
	AttachedAt  *metav1.Time `json:"attachedAt,omitempty"`
}

Attachment is one broadcast bound to the room.

func (*Attachment) DeepCopyInto

func (in *Attachment) DeepCopyInto(out *Attachment)

DeepCopyInto copies the receiver into out.

type FileRoom

type FileRoom struct {
	Code          string `json:"code"`
	DisplayName   string `json:"displayName,omitempty"`
	AttachSecret  string `json:"attachSecret,omitempty"`
	MaxBroadcasts int    `json:"maxBroadcasts,omitempty"`
	// MaxParticipants overrides -max-room-participants for this room.
	MaxParticipants int `json:"maxParticipants,omitempty"`
}

FileRoom is one static room definition in the -rooms-file source (docs/44 §4.3, "non-cluster mode"): the JSON shape an operator writes by hand where there is no Kubernetes API. The attach secret is inline here because there is no Secret object to point at; the file's own mode is the protection, exactly as -publish-secret's is.

type Integrations

type Integrations struct {
	// Mumble is the voice-bridge mapping reserved by docs/44 §4.11.
	Mumble *MumbleIntegration `json:"mumble,omitempty"`
}

Integrations is the reserved hook block (docs/44 §4.11). Nothing reads it in v1; it exists so a later milestone adds a field instead of a version.

func (*Integrations) DeepCopyInto

func (in *Integrations) DeepCopyInto(out *Integrations)

DeepCopyInto copies the receiver into out.

type Lease

type Lease struct {
	Holder     string       `json:"holder,omitempty"`
	Addr       string       `json:"addr,omitempty"`
	Generation int64        `json:"generation"`
	RenewedAt  *metav1.Time `json:"renewedAt,omitempty"`
}

Lease is the home-pod ownership record (docs/44 D6). Holder empty with a non-zero Generation is a released lease: the next join claims it without waiting for staleness.

func (*Lease) DeepCopyInto

func (in *Lease) DeepCopyInto(out *Lease)

DeepCopyInto copies the receiver into out.

type MumbleIntegration

type MumbleIntegration struct {
	Server        string `json:"server,omitempty"`
	ChannelPrefix string `json:"channelPrefix,omitempty"`
}

MumbleIntegration is the reserved shape of the Mumble mapping.

func (*MumbleIntegration) DeepCopyInto

func (in *MumbleIntegration) DeepCopyInto(out *MumbleIntegration)

DeepCopyInto copies the receiver into out.

type Room

type Room struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   RoomSpec   `json:"spec"`
	Status RoomStatus `json:"status,omitempty"`
}

Room is one room: a static one written by the admin portal or kubectl, or a dynamic one the relay creates at mint (docs/44 D4, D5). spec is written by whoever creates the room; status is written only by the home pod.

func (*Room) DeepCopy

func (in *Room) DeepCopy() *Room

DeepCopy returns a deep copy.

func (*Room) DeepCopyInto

func (in *Room) DeepCopyInto(out *Room)

DeepCopyInto copies the receiver into out.

func (*Room) DeepCopyObject

func (in *Room) DeepCopyObject() runtime.Object

DeepCopyObject satisfies runtime.Object.

func (*Room) ScreeningExempt added in v0.33.0

func (r *Room) ScreeningExempt() bool

ScreeningExempt reports whether broadcasts attached to the room skip content screening. It fails closed: a room whose spec does not pass ValidateScreening — a dynamic room someone marked exempt with kubectl, a static one whose secret reference was removed — is screened.

type RoomList

type RoomList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []Room `json:"items"`
}

RoomList is the list type for the Room kind.

func (*RoomList) DeepCopy

func (in *RoomList) DeepCopy() *RoomList

DeepCopy returns a deep copy.

func (*RoomList) DeepCopyInto

func (in *RoomList) DeepCopyInto(out *RoomList)

DeepCopyInto copies the receiver into out.

func (*RoomList) DeepCopyObject

func (in *RoomList) DeepCopyObject() runtime.Object

DeepCopyObject satisfies runtime.Object.

type RoomSpec

type RoomSpec struct {
	// Kind is KindStatic or KindDynamic.
	Kind string `json:"kind"`
	// DisplayCode is the code as configured ("TuhisRoom"); dynamic rooms
	// omit it and display the upper-cased name.
	DisplayCode string `json:"displayCode,omitempty"`
	// DisplayName is an optional human title.
	DisplayName string `json:"displayName,omitempty"`
	// AttachSecretRef names the Secret key holding a static room's attach
	// secret (docs/44 D8). Absent means anyone may attach.
	AttachSecretRef *SecretKeyRef `json:"attachSecretRef,omitempty"`
	// MaxBroadcasts overrides -max-room-broadcasts for this room; 0 means
	// the fleet default.
	MaxBroadcasts int `json:"maxBroadcasts,omitempty"`
	// Integrations is reserved (docs/44 D18, §4.11); empty in v1.
	Integrations Integrations `json:"integrations,omitempty"`
	// Screening is ScreeningExempt to exempt the room's broadcasts from R40's
	// content screening, or empty (docs/71 D11). Only a static room with an
	// attach secret may be exempt — ValidateScreening and
	// ScreeningExempt both hold that rule, so a CR applied by hand that breaks
	// it is screened anyway.
	Screening string `json:"screening,omitempty"`
	// Pop names the R74 PoP whose party wall this static room is (docs/76
	// item 33). Such a room accepts vouched attaches only, from that PoP's
	// link; empty means an ordinary room.
	Pop string `json:"pop,omitempty"`
	// MaxParticipants overrides -max-room-participants for this room; 0
	// means the fleet default. A party wall needs more than 50.
	MaxParticipants int `json:"maxParticipants,omitempty"`
}

RoomSpec mirrors the YAML in docs/44 §4.3.

func (*RoomSpec) DeepCopyInto

func (in *RoomSpec) DeepCopyInto(out *RoomSpec)

DeepCopyInto copies the receiver into out.

type RoomStatus

type RoomStatus struct {
	// CreatorTokenFingerprint is Fingerprint(creator token) for a dynamic
	// room; never the token.
	CreatorTokenFingerprint string `json:"creatorTokenFingerprint,omitempty"`
	// Key is the fleet's HMAC'd handle for the code — the same
	// -stats-key digest /statusz, metrics and telemetry use (docs/44 D16).
	// Written by the home pod so gawk-admin, which never holds the stats
	// key, can name the room in webhooks and deep links without the code.
	Key string `json:"key,omitempty"`
	// CreatedAt is when the room was minted (dynamic) or first adopted.
	CreatedAt *metav1.Time `json:"createdAt,omitempty"`
	// Attachments is rebuilt by the home pod on adoption. It carries raw
	// broadcast IDs: the Kubernetes API is internal (docs/44 §4.3).
	Attachments []Attachment `json:"attachments,omitempty"`
	// Lease is the home-pod lease with the R17 generation-CAS semantics.
	Lease *Lease `json:"lease,omitempty"`
	// EmptySince is set by the home pod when the roster empties (dynamic
	// rooms only) and cleared by the next join.
	EmptySince *metav1.Time `json:"emptySince,omitempty"`
}

RoomStatus is written only by the home pod (docs/44 §4.3).

func (*RoomStatus) DeepCopyInto

func (in *RoomStatus) DeepCopyInto(out *RoomStatus)

DeepCopyInto copies the receiver into out.

type SecretKeyRef

type SecretKeyRef struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

SecretKeyRef points at one key of a Kubernetes Secret in the room's namespace.

func (*SecretKeyRef) DeepCopyInto

func (in *SecretKeyRef) DeepCopyInto(out *SecretKeyRef)

DeepCopyInto copies the receiver into out.

Jump to

Keyboard shortcuts

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