config

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config owns Hosted and App Local configuration and ICE discovery. Callers provide configuration inputs; loading opens no runtime resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IceConfig

func IceConfig(c Config) protocol.IceConfig

func NATPredictionStunURLs

func NATPredictionStunURLs(stunURLs []string) []string

NATPredictionStunURLs returns the two auxiliary listeners derived from the first ordinary STUN authority on UDP 3478.

func Origin

func Origin(parsed *url.URL) string

Origin ports the WHATWG URL `origin` getter for the http/https/ws/wss schemes this package accepts: new URL("https://Example.com:443/").origin is "https://example.com". It is exported so app and cmd can compare request origins without a second copy of the rule. Invalid hosts/ports return empty.

Types

type Config

type Config struct {
	Env           Environment
	Port          int
	ListenHost    string
	PublicBaseURL *url.URL
	// AllowedOrigins is a membership test only; map order is not observable.
	AllowedOrigins            map[string]struct{}
	SiteAccessPassword        string
	RoomDatabasePath          string
	RoomEmptyTimeoutSeconds   int
	MaxViewersPerRoom         int
	EndpointMediaCopyCapacity int
	SFU                       *SFUConfig
	STUNURLs                  []string
	// STUNListenAddresses is populated only by Hosted configuration. Local
	// discovery URLs do not make the Client an externally reachable STUN server.
	STUNListenAddresses  []string
	NATPredictionEnabled bool
	// NATPredictionSTUNURLs is nil when unset, which IceConfig distinguishes
	// from a configured empty list.
	NATPredictionSTUNURLs []string
}

Config describes runtime configuration. Zero values mean open site access, process-memory rooms, and no SFU fallback.

func Load

func Load(env map[string]string) (Config, error)

Load validates the whole process environment. Presence, not emptiness, distinguishes an explicit value from an unset value where that distinction is part of the contract.

func Local

func Local(options LocalOptions) (Config, error)

type Environment

type Environment string

Environment selects development-only behavior. A stale unit file must fail closed rather than fall back to development.

const (
	EnvironmentDevelopment Environment = "development"
	EnvironmentProduction  Environment = "production"
)

The two accepted PIIK_ENV values.

type LocalOptions

type LocalOptions struct {
	// Port 0 selects the default 8787.
	Port                  int
	PublicAddress         string
	PublicOrigin          string
	AllowedAddresses      []string
	SiteAccessPassword    string
	STUNURLs              []string
	NATPredictionSTUNURLs []string
}

LocalOptions describes App-selected Local composition. It never reads the process environment.

type SFUConfig

type SFUConfig struct {
	ListenHost string
	Port       int
	PublicIP   string
	Only       bool
}

SFUConfig enables the embedded UDP media listener.

Jump to

Keyboard shortcuts

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