Go service for temporary HLS live-stream access links managed through Telegram.
- Creates temporary or permanent watch links from Telegram
- Lists active links and disables them on demand
- Exposes a watch page at
/live/stream/{token} - Proxies HLS playback through
/play/*after token validation - Accepts RTMP publishing through MediaMTX on
live/stream - Stores links in SQLite
- Runs as a Compose stack with the Go service, MediaMTX, and Caddy
A typical operator flow looks like this:
- Start the stack.
- Publish video to MediaMTX over RTMP.
- Create a watch link from Telegram.
- Open the generated URL in a browser.
- Disable the link when access should end.
- Go 1.26+ for source builds
- Golangci-lint v2 for local checks
- Bun and prek for repository-wide formatting and git hooks
- Docker and Docker Compose for the full stack
- Telegram bot token
- Telegram chat IDs allowed to control the bot
- Public
BASE_URLreachable by viewers - RTMP publisher credentials for MediaMTX
make ensure-envFill in these values in .env:
TELEGRAM_BOT_TOKENALLOWED_CHAT_IDSBASE_URLMEDIAMTX_PUBLISH_USERMEDIAMTX_PUBLISH_PASSWORD
For phone access on the same Wi-Fi, set BASE_URL to the machine's LAN IP and disable secure
cookies for local HTTP:
BASE_URL=http://192.168.1.42
COOKIE_SECURE=false| Name | Required | Default | Description |
|---|---|---|---|
HTTP_ADDR |
No | :8080 |
HTTP listen address for the Go service |
HTTP_TRUSTED_PROXY_COUNT |
No | 1 |
Trusted reverse proxy count for X-Forwarded-For |
BASE_URL |
Yes | - | Public base URL used in links and by Caddy |
DB_PATH |
No | ./db.sqlite |
SQLite database path |
TELEGRAM_BOT_TOKEN |
Yes | - | Telegram bot token |
ALLOWED_CHAT_IDS |
Yes | - | Comma-separated Telegram chat IDs |
MEDIAMTX_HLS_BASE_URL |
Yes | - | Internal HLS base URL for stream probing/playback |
COOKIE_SECURE |
No | true |
Marks playback cookies as Secure |
DEFAULT_LINK_TTL |
No | 1h |
Default temporary link duration |
LINK_TTL_OPTIONS |
No | 30m,1h,3h |
Temporary link durations shown in Telegram |
TIME_ZONE |
No | UTC |
IANA time zone used in bot responses |
LOG_LEVEL |
No | info |
Log level for the Go service |
MEDIAMTX_PUBLISH_USER |
Yes in Docker Compose | - | RTMP publish username |
MEDIAMTX_PUBLISH_PASSWORD |
Yes in Docker Compose | - | RTMP publish password |
See .env.example for a complete example.
Service commands:
make start
make stop
make restartThe Compose stack uses:
tempstream- Go HTTP service and Telegram bot fromghcr.io/hu553in/tempstream;latestfollowsmain, whilesha-*tags are immutablemediamtx- RTMP ingest and HLS outputcaddy- public reverse proxy
The bot is the operator interface:
/new <duration>for a temporary link/newpermfor a permanent link/activeto list active links/statusto show stream status/off IDto disable a link by ID/offlastto disable the latest active link/whoamito show the current chat ID
Links returned by the bot include a direct disable action.
The configured MediaMTX path is live/stream:
rtmp://HOST:1935/live/stream?user=MEDIAMTX_PUBLISH_USER&pass=MEDIAMTX_PUBLISH_PASSWORD
Example:
rtmp://192.168.1.42:1935/live/stream?user=publisher&pass=secret
Create a link from Telegram, then open the returned URL:
http://HOST/live/stream/<token>
- The Go service exposes
/healthz,/live/stream/{token}, and/play/* /live/stream/{token}validates the token, sets a playback cookie, and renders the watch page/play/*validates the playback cookie again and proxies HLS traffic to MediaMTX- MediaMTX accepts RTMP and remuxes the stream to low-latency HLS
- Caddy serves
BASE_URLand reverse-proxies traffic to the Go service - In Docker Compose, SQLite data lives in the
tempstream_datavolume at/data/db.sqlite - If a link expires or is disabled, playback stops and the page shows a clear error state
Without Docker, build only the Go service:
make build
dist/tempstreamA reachable SQLite path, a Telegram bot token, and a running MediaMTX instance are still required.
make install-deps
prek install
make checkUse make check-fix to apply formatting before running the same full gate.
Focused checks:
make lint
make lint-fix
make check-generated
make check-deps
make check-vulns
make check-configmake check-config validates both the Compose stack and its Caddyfile.
Generated SQL:
make sqlcMigrations are embedded into the binary with go:embed, while sqlc uses the same migration
directory on disk as the schema source.