Files
piik/.env.example
T
AAA 23c76cfb75 fix(rooms): reclaim empty rooms on public sites (#456)
Public sites can exhaust the four-digit room-code pool because retained room authority has no default expiry. Add an opt-in empty-room timeout and reclaim the oldest eligible empty room when capacity is exhausted. Connected Hosts and Viewers retain their rooms through sharing, pause and idle chat; the existing reconnect grace protects early reclamation.

The default remains disabled, including App Local and the internal deployment. The public Demo will use `ROOM_EMPTY_TIMEOUT_SECONDS=3600`. Retirement reuses the storage-first deletion and signaling cleanup owners; no protocol or SQLite schema changes are required.

Validation: Web type-check, 81 test files / 1372 tests and production build; Go core tests, formatting, vet and target builds; documentation/project hygiene; access-privacy gate; live server expiry/occupied-room check. Regression coverage includes all 9000 codes, restart, stale credentials, reconnects, revocation and atomic storage failure. Native device behavior is unchanged; physical macOS/Linux acceptance retains its documented limits.

## Release notes

### 中文

这是一次面向公共站点的维护更新,解决长期保留的空房间占满房间号的问题。

- 管理员可配置空房间回收时长;号码用满时,优先回收过期空房间,再按创建顺序回收符合条件的空房间。在线分享、暂停和聊天均会保留。
- 房间号确实已用满时,界面会显示更明确的提示。
- 自动回收默认关闭。公共站点可设置 `ROOM_EMPTY_TIMEOUT_SECONDS=3600`,在房间连续无人在线一小时后回收;未配置的站点保持原有行为。

### English

This maintenance release helps public sites avoid exhausting room codes through indefinitely retained empty rooms.

- Operators can configure an empty-room timeout. When all codes are in use, allocation reclaims expired empty rooms first, then the oldest eligible empty room. Connected sharing, paused sessions and chat remain protected.
- Capacity errors now provide clearer guidance when no room code is available.
- Automatic reclamation is disabled by default. Public sites can set `ROOM_EMPTY_TIMEOUT_SECONDS=3600` to retire rooms after one continuous hour with no connected participants. Unconfigured sites retain their existing behavior.
2026-10-06 12:43:49 +08:00

78 lines
3.8 KiB
Bash

# Application
# Use 127.0.0.1 instead when only a same-host reverse proxy should connect.
LISTEN_HOST=0.0.0.0
PORT=8787
# For LAN viewers, replace localhost with this computer's LAN address.
PUBLIC_BASE_URL=http://localhost:8787
# Leave empty to follow PUBLIC_BASE_URL. For multiple trusted browser addresses,
# list all exact origins (scheme, host and port), including PUBLIC_BASE_URL.
ALLOWED_ORIGINS=
# Optional site access password in every environment. Unset or empty allows
# entry without a site password; room ownership and invitations still apply.
# Non-empty values are matched exactly; spaces and Unicode are supported.
SITE_ACCESS_PASSWORD=
# Rooms persist in rooms.sqlite under the working directory by default (also
# when blank). Set :memory: explicitly for process-memory rooms. Deployments
# should use an access-restricted absolute path outside the release directory,
# preserving the existing database and its writable parent across updates.
ROOM_DATABASE_PATH=
# Optional empty-room recycling. 0 keeps rooms indefinitely (default).
# 3600 expires rooms after an hour with no authenticated participants; when
# all codes are used, the oldest empty room may be reclaimed earlier.
ROOM_EMPTY_TIMEOUT_SECONDS=0
# Viewers per room, excluding the Host. Valid range: 1..20; default: 20.
MAX_VIEWERS_PER_ROOM=20
# Bounded standard-WebRTC relay/SFU controller is active for every room.
# One steady outbound media-copy capacity for every non-server endpoint.
# A peer child or Host SFU publication consumes one copy. Valid values: 1, 2, 3.
ENDPOINT_MEDIA_COPY_CAPACITY=2
# During pre-release route canaries, this enables sanitized room/ordinal events.
# PIIK_DEBUG=route
# Optional in-process automatic SFU fallback. Set SFU_UDP_PORT=7882 to enable;
# unset or empty disables it and fixes Privacy mode on for every room.
# STUN/signaling/P2P remain available. Local App modes never create this listener.
# Ingress uses the 9000-room code capacity; egress uses that capacity times the
# configured per-room Viewer admission.
SFU_UDP_PORT=
# IPv4 bind address, independent of HTTP LISTEN_HOST and advertised media IP.
SFU_LISTEN_HOST=0.0.0.0
# Optional advertised IPv4 override when the listener's address is behind NAT.
SFU_PUBLIC_IP=
# Require server media for every room instead of P2P-first. Requires SFU_UDP_PORT.
SFU_ONLY=false
# Ordinary peer ICE discovery. Production requires at least one STUN URL.
# These are advertised addresses, not local listener addresses. They may use
# an unproxied DNS name distinct from PUBLIC_BASE_URL. Separate URLs with commas.
STUN_URLS=
# Hosted STUN is in-process. With STUN_URLS configured, bind this IPv4 address
# on UDP 3478 (also 3479/3480 below). It is independent of HTTP LISTEN_HOST.
# Local App modes never create these listeners, even with public discovery.
STUN_LISTEN_HOST=0.0.0.0
# Optional bounded NAT traversal support. The per-share switch stays visible;
# it is locked off when disabled, and defaults on when enabled after all three
# local STUN listeners bind. Browser
# P2P derives UDP 3479/3480 from the first STUN_URLS endpoint on UDP 3478.
# Cloud security-group and host firewall rules must also allow these UDP ports.
NAT_PREDICTION_ENABLED=false
# Development example (two processes): Vite serves the Browser on 8787 and
# proxies /api, /healthz and /signal to the Go server on 8788. Keep
# PUBLIC_BASE_URL and ALLOWED_ORIGINS on the Browser origin above.
# PIIK_ENV=development
# PORT=8788
# Production example (keep any chosen password in an untracked environment):
# PIIK_ENV=production
# PUBLIC_BASE_URL=https://share.example.com
# ALLOWED_ORIGINS=https://share.example.com
# SITE_ACCESS_PASSWORD=
# STUN_URLS=stun:stun.example.com:3478
# NAT_PREDICTION_ENABLED=true
# Automatic SFU fallback (does not replace STUN above):
# SFU_UDP_PORT=7882
# SFU_PUBLIC_IP=198.51.100.5
# ENDPOINT_MEDIA_COPY_CAPACITY=2