Files

639 lines
32 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Optional local config file for telesrv.
# Copy to .env for local development. Do not commit real tokens or passwords.
# Complete reference / 完整参数手册:
# docs/configuration.en.md
# docs/configuration.zh-CN.md
## Server & Network -- Where the server listens and what address it tells clients to connect to.
TELESRV_LISTEN=0.0.0.0:2398
TELESRV_ADVERTISE_IP=127.0.0.1
TELESRV_DC=2
# ISO 3166-1 alpha-2 code returned by help.getNearestDc. CN preselects +86.
TELESRV_DEFAULT_COUNTRY_CODE=CN
# Single-backend default: accept any client wire DC label during key exchange.
TELESRV_STRICT_DC_CHECK=false
# Phone-number format policy. false (default) accepts canonical country-aware
# numbers and 4-32 digit nonzero-leading identities outside the numbering plan.
# true additionally requires an assigned ordinary phone-number range.
# Virtual +888 identities retain their 7-15 digit rule in both modes.
# The reserved service identity +42777 can never log in.
TELESRV_CHECK_NUMBER_FORMAT=false
# Where the panel-editable server identity lives: the name/description/icon and
# the login-notification template overrides, all managed from Admin → Server
# Settings (see internal/identity). Read every time a login notification is sent.
TELESRV_IDENTITY_DIR=data/identity
## WebSocket -- The WebSocket transport and the Origin allow-list that guards its handshake.
# Enables the WebSocket transport for clients that cannot use the raw TCP one.
# Turning it off does not affect TCP clients.
TELESRV_WEBSOCKET_ENABLE=true
# Comma-separated Origin allow-list for the WebSocket handshake. The default
# only accepts the local web client; a public deployment must list the origin
# its browser client is actually served from.
TELESRV_WEBSOCKET_ALLOWED_ORIGINS=http://localhost:1234,http://127.0.0.1:1234
## Phone Login Codes -- How a login code gets to a phone number when someone signs in.
TELESRV_DEV_AUTH_CODE=12345
TELESRV_AUTH_CODE_TTL=5m
TELESRV_AUTH_CODE_MAX_ATTEMPTS=5
# Unauthenticated login-code issuance uses the same limits for existing and
# unknown phones. Phone numbers are SHA-256 digested before becoming Redis keys.
TELESRV_AUTH_CODE_PHONE_RATE_LIMIT=5
TELESRV_AUTH_CODE_AUTH_KEY_RATE_LIMIT=20
TELESRV_AUTH_CODE_RATE_WINDOW=10m
# The message sent from the official system account (777000) on every completed
# sign-in -- a lightweight security notice, not the login code itself.
# {{server_name}} is replaced with the configured identity name (or the product
# name when unset). Leave empty to use the built-in copy; Admin → Server
# Settings can override these live without a restart -- these env vars are only
# the fallback.
TELESRV_WELCOME_MESSAGE_PHONE_TEMPLATE=
TELESRV_WELCOME_MESSAGE_EMAIL_TEMPLATE=
# The message sent from 777000 carrying the actual login code. Must contain the
# {{code}} placeholder exactly once (the real code is inserted and bolded there);
# {{server_name}} may appear any number of times. Leave empty for the built-in
# copy; Admin → Server Settings can override this live (and rejects a save that
# does not contain {{code}} exactly once).
TELESRV_LOGIN_CODE_MESSAGE_TEMPLATE=
## Advanced: Connection & RPC Budgets -- MTProto edge budgets (frame bytes, RPC inflight, outbound queue). Defaults are safe; tune only under load.
# MTProto admission and shared inbound RPC budgets. Negative connection/handshake limits disable
# that gate; non-positive RPC values fall back to the built-in safe defaults.
TELESRV_MTPROTO_MAX_CONNECTIONS=200000
TELESRV_MTPROTO_MAX_CONNECTIONS_PER_IP=4096
TELESRV_MTPROTO_MAX_CONCURRENT_HANDSHAKES=256
TELESRV_MTPROTO_RPC_MAX_INFLIGHT=32
TELESRV_MTPROTO_RPC_QUEUE_SIZE=64
TELESRV_MTPROTO_RPC_TIMEOUT=30s
TELESRV_MTPROTO_RPC_GLOBAL_WORKERS=256
TELESRV_MTPROTO_RPC_GLOBAL_MAX_TASKS=32768
TELESRV_MTPROTO_RPC_GLOBAL_MAX_BYTES=536870912
# Metadata-only rpc_result receipt budgets: global >= auth >= session. ACK deletes immediately;
# 331s is only the no-ACK horizon. Payloads live solely in the logical-session outbound budget.
TELESRV_MTPROTO_RPC_EXECUTION_MAX_ENTRIES=262144
TELESRV_MTPROTO_RPC_EXECUTION_AUTH_MAX_ENTRIES=32768
TELESRV_MTPROTO_RPC_EXECUTION_SESSION_MAX_ENTRIES=16384
TELESRV_MTPROTO_RPC_EXECUTION_PENDING_PER_AUTH=2048
# Process-wide in-flight transport wire + decrypted plaintext reservation.
TELESRV_MTPROTO_INBOUND_FRAME_GLOBAL_MAX_BYTES=536870912
# Per-connection outbound mailboxes (normal/control) and process-wide resend pending bodies.
TELESRV_MTPROTO_OUTBOUND_QUEUE_SIZE=128
TELESRV_MTPROTO_OUTBOUND_CONTROL_QUEUE_SIZE=32
TELESRV_MTPROTO_OUTBOUND_TRACKED_GLOBAL_MAX_BYTES=536870912
# Independent bootstrap/convergence RPC result reserve; bulk cannot consume it.
TELESRV_MTPROTO_OUTBOUND_CRITICAL_GLOBAL_MAX_BYTES=67108864
# Concurrent encrypted wire/codec/obfuscation scratch (shared bounded pool, not per connection).
TELESRV_MTPROTO_OUTBOUND_WRITE_GLOBAL_MAX_BYTES=536870912
## SMS / OTP Delivery -- How a phone-login code is delivered (development or webhook).
# OTP delivery routing. "development" preserves the fixed phone code. "webhook"
# generates a random SMS code and sends it with the versioned protocol documented
# in docs/otp-delivery.md. For an existing account, both modes first create the
# durable 777000 message; Webhook is an additional delivery channel for that code.
TELESRV_PHONE_CODE_DELIVERY_PROVIDER=development
TELESRV_PHONE_CODE_LENGTH=5
TELESRV_OTP_WEBHOOK_URL=
TELESRV_OTP_WEBHOOK_SECRET=
TELESRV_OTP_WEBHOOK_TIMEOUT=5s
## Email Login & Signup -- Signing in (or registering) with an email address instead of a phone number.
# Optional login-email verification. EMAIL_CODE_DELIVERY_PROVIDER may be smtp
# or webhook. Existing-account login codes are also mirrored into 777000 before
# provider delivery; setup/change codes are provider-only. REQUIRE_SETUP forces
# accounts without a login email to set one during the phone login flow.
TELESRV_LOGIN_EMAIL_ENABLE=false
TELESRV_LOGIN_EMAIL_REQUIRE_SETUP=false
TELESRV_LOGIN_EMAIL_CODE_LENGTH=6
TELESRV_EMAIL_CODE_DELIVERY_PROVIDER=smtp
## SMTP (Outgoing Email) -- The mail server used to send login/signup codes by email.
TELESRV_SMTP_HOST=
TELESRV_SMTP_PORT=587
TELESRV_SMTP_USERNAME=
TELESRV_SMTP_PASSWORD=
TELESRV_SMTP_FROM=
# Empty inherits TELESRV_BRAND_PRODUCT_NAME.
TELESRV_SMTP_FROM_NAME=
TELESRV_SMTP_TLS=starttls
TELESRV_SMTP_TIMEOUT=10s
## Public Links -- The base URL public links and the web build resolve against.
# Client-visible telesrv links. This is an HTTP(S) URL, not a listen address.
# Production uses https://telesrv.net. For local link/deeplink smoke tests use
# http://127.0.0.1:2401. Invalid schemes, credentials, query strings, fragments,
# or a missing host fail startup instead of silently falling back.
TELESRV_PUBLIC_BASE_URL=https://telesrv.net
## Branding -- Deployment-wide user-visible product identity.
# Deployment-wide user-visible product identity. These values are loaded as
# one validated snapshot before any store, service, or RPC handler is created.
# They do not rename protocol identifiers, client detection tokens, metrics,
# database objects, module paths, or compatibility headers.
TELESRV_BRAND_PRODUCT_NAME=Telesrv
TELESRV_BRAND_PRODUCT_USERNAME=telesrv
TELESRV_BRAND_DESKTOP_APP_NAME=Telesrv Desktop
TELESRV_BRAND_ANDROID_APP_NAME=Telesrv Android
TELESRV_BRAND_IOS_APP_NAME=Telesrv iOS
TELESRV_BRAND_MACOS_APP_NAME=Telesrv macOS
TELESRV_BRAND_WEB_A_APP_NAME=Telesrv Web A
TELESRV_BRAND_WEB_K_APP_NAME=Telesrv Web K
TELESRV_BRAND_PREMIUM_NAME=Telesrv Premium
TELESRV_BRAND_STARS_NAME=Telesrv Stars
TELESRV_PREMIUM_PLANS=1:30:500,3:90:1000,6:180:1800,12:365:3200
# Free Premium months granted to a newly registered account. 0 turns the grant
# off. The one-off grant for accounts that already existed is a backfill
# migration (0094) and is not affected by this setting.
TELESRV_PREMIUM_GRANT_MONTHS=3
# Channels (numeric ids, comma-separated) that every newly registered account
# joins automatically. Empty turns the hook off. Existing accounts are never
# joined retroactively by the server: run scripts/subscribe.sh once to store the
# ids here and backfill current accounts, or scripts/fixsubscribe.sh to re-run
# the backfill at any time (both accept @usernames as well as ids).
TELESRV_AUTOSUBSCRIBE_CHANNELS=
## Client Updates -- Built-in native-client update service.
# Optional native-client update service. PUBLIC_URL is written into
# help.getConfig.autoupdate_url_prefix and must be reachable by clients.
# SERVICE_URL may point at a private/loopback route used by telesrv for
# help.getAppUpdate; when omitted it defaults to PUBLIC_URL. Leave PUBLIC_URL
# empty to keep the feature disabled.
TELESRV_UPDATE_PUBLIC_URL=
TELESRV_UPDATE_SERVICE_URL=
TELESRV_UPDATE_REQUEST_TIMEOUT=2s
# Standalone cmd/telesrv-update settings.
TELESRV_UPDATE_LISTEN=127.0.0.1:2402
TELESRV_UPDATE_MANIFEST=data/updates/manifest.json
TELESRV_UPDATE_FILES_DIR=data/updates/files
## Public App Links & Notices -- Custom scheme, host-based link root, web client, and the SCAM/FAKE warnings.
# Public landing pages auto-open this custom scheme. It must match the scheme
# registered by every patched client build; tg/http/https are rejected.
TELESRV_PUBLIC_APP_SCHEME=telesrv
# Optional host-based app-link root for multi-server clients. When set, public
# links use e.g. owpg://example.com/oauth and owpg://example.com/username while
# the scheme above remains accepted for existing/in-flight links. The value
# must be exactly <custom-scheme>://<host>, without port/path/query/fragment.
TELESRV_PUBLIC_APP_LINK_BASE=
# Web client target and optional display-brand override used by public landing
# pages. Empty app name inherits TELESRV_BRAND_PRODUCT_NAME.
TELESRV_PUBLIC_WEB_BASE_URL=https://weba.telesrv.net
TELESRV_PUBLIC_APP_NAME=
# Profile warning text injected into getFullUser/getFullChannel About for peers
# flagged SCAM/FAKE from the admin panel. It becomes the first line of the
# description, the owner's own text follows after a newline:
# ⚠️ Warning: This account has received numerous complaints related to fraud or
# attempts to impersonate an official account. Be cautious, especially if you
# are asked for money.
# the description the owner wrote
# The defaults below are the shipped English wording; an empty value falls back
# to exactly these strings. Quote values: they contain punctuation and spaces.
# Clients cannot localize server text, so set your audience language here, e.g.
# "⚠️ Аккаунт помечен как SCAM.".
# The stored bio/description is never overwritten; the warning is re-applied from
# the flag on every read and survives the owner editing their description. The
# same line also rides the chat-invite preview a non-member sees. About privacy
# hides the entire field from viewers without access. Self users and channel
# editors receive the original stored text, so saving never persists a warning.
TELESRV_SCAM_WARNING="⚠️ Warning: This account has received numerous complaints related to fraud or attempts to impersonate an official account. Be cautious, especially if you are asked for money."
TELESRV_FAKE_WARNING="⚠️ Warning: Many users have reported that this account is impersonating a well-known person or organization."
## Admin Panel -- Login, access, RBAC and the loopback listeners for the web-based admin dashboard.
# Admin API / Admin UI 配置
#
# TELESRV_ADMIN_API_TOKEN 是主服务 (cmd/telesrv) 暴露 Admin REST API 的鉴权 token,
# 也是 Admin UI (cmd/telesrv-admin) 调用 Admin API 时使用的凭证。
# 重要:主服务与 Admin UI 必须使用完全相同的 TELESRV_ADMIN_API_TOKEN,否则管理后台无法执行写操作。
TELESRV_ADMIN_API_TOKEN=
# TELESRV_ADMIN_UI_PASSWORD 是登录管理后台的密码;
# 也可改用 TELESRV_ADMIN_UI_TOKEN,二者至少填一个。
TELESRV_ADMIN_UI_PASSWORD=
TELESRV_ADMIN_UI_TOKEN=
# TELESRV_ADMIN_SESSION_KEY 用于加密 Admin UI 的登录 session cookie。
# 生产环境请使用至少 32 字节的强随机字符串,修改后会导致已登录会话失效。
TELESRV_ADMIN_SESSION_KEY=
# 主服务 Admin API 默认关闭;Admin UI 写操作需要同时配置强 token 并显式开启该 loopback 监听地址。
TELESRV_ADMIN_API_ADDR=
# Admin UI 监听地址,默认值通常无需修改;RTMP ingest 保留 2400。
TELESRV_ADMIN_UI_ADDR=127.0.0.1:2600
# Permissions granted to an Admin UI session that logged in with
# TELESRV_ADMIN_UI_PASSWORD / _TOKEN. Comma-separated; "*" means every
# permission and is the default, so enabling RBAC never locks an operator out of
# a panel that worked before. Names are letters/digits/._:- and may end in
# "namespace.*" to grant a whole namespace.
TELESRV_ADMIN_UI_PERMISSIONS=*
# Additional Admin API bearer tokens with a bounded permission set each, so an
# integration gets exactly the rights it needs instead of the unrestricted
# TELESRV_ADMIN_API_TOKEN. Format: "name:token:perm1,perm2" entries separated by
# ';'. A token may not contain ':' or whitespace, names and tokens must be
# unique, and reusing TELESRV_ADMIN_API_TOKEN here is refused; any malformed
# entry fails startup rather than silently granting or dropping rights.
TELESRV_ADMIN_SCOPED_TOKENS=
## Database & Redis -- Connection settings for Postgres and the ephemeral Redis store.
TELESRV_POSTGRES_PASSWORD=telesrv
# Full DSN override; when empty the server builds the DSN from
# TELESRV_POSTGRES_PASSWORD above (local default host/port/db). Production
# should set it explicitly. Secrets: never commit a real DSN.
# TELESRV_POSTGRES_DSN=postgres://user:password@host:5432/telesrv_main?sslmode=disable
TELESRV_REDIS_ADDR=127.0.0.1:6399
TELESRV_REDIS_PASSWORD=
TELESRV_REDIS_DB=0
## Advanced: Retention & GC -- Update-row and outbox-pruning floors. Defaults are safe.
# Bounded retention/GC. User/channel update rows are only pruned behind protocol-safe floors.
TELESRV_UPDATE_EVENT_RETENTION=168h
# Webhooks may reach only public IPs by default. Enable only if every bot is trusted:
# this grants all bots access to loopback and internal services. HTTP proxies are not used.
TELESRV_BOT_API_WEBHOOK_ALLOW_PRIVATE_NETWORKS=false
TELESRV_BOT_API_UPDATE_RETENTION=24h
TELESRV_ORPHAN_AUTH_KEY_RETENTION=24h
# Terminal failed outbox heads are kept briefly for diagnosis, then only the online
# delivery task is removed. The durable update remains available to getDifference.
TELESRV_OUTBOX_POISON_RETENTION=1m
TELESRV_OUTBOX_POISON_CLEANUP_INTERVAL=15s
TELESRV_RETENTION_INTERVAL=1h
TELESRV_RETENTION_BATCH=10000
## Advanced: Auth Key Cache -- PFS temporary-key binding cache (tuning).
# PFS temp->perm binding cache; write-side revoke/rebind invalidates entries precisely.
TELESRV_TEMP_KEY_CACHE_MAX_ENTRIES=262144
TELESRV_TEMP_KEY_CACHE_TTL=30m
## Maps -- Optional map previews for patched clients.
# Optional. Enables Mapbox-backed map previews and TDesktop map picker config.
TELESRV_MAPBOX_TOKEN=
TELESRV_MAPTILE_CACHE_DIR=data/maptiles
## GeoIP -- Optional country/region text for account.getAuthorizations.
# Optional. The protocol has no counterpart for help.requestIpAddress, so session
# country/region is resolved by an operator-supplied HTTP backend. Leave empty to
# keep the feature disabled: the session list then returns the "Unknown"
# placeholder exactly as before.
#
# TELESRV_GEOIP_ENDPOINTS is an ORDERED, comma-separated failover chain. Every entry
# is a URL template and MUST contain the {ip} placeholder. The first entry is the
# primary; any address the current backend cannot resolve (or that backend being
# rate-limited/unreachable) falls through to the next one. Order matters: a more
# accurate primary means the later backends are consulted less often, which matters
# because every one of them is a shared free quota.
#
# The four ready-made entries below are what this build has been measured against
# (2026-09). Each of them fails in its own way, which is exactly why several are
# listed: reallyfreegeoip.org returns HTTP 429 after a few consecutive requests
# (~0.7s per call, ~60s to recover); geojs.io only has ASN-level coverage, so some
# addresses have no country field at all; hackmyip.com intermittently answers HTTP
# 400 with {"success":false}; ipapi.is reports is_bogon for reserved ranges. Drop the
# ones you do not want, or add your own (an unrecognised host falls back to a
# permissive generic JSON parser).
#
# Enabling this sends session IPs to the selected providers. Review their privacy
# policies before opting in, or use a self-hosted backend. For example:
# TELESRV_GEOIP_ENDPOINTS=https://api.ipapi.is/?q={ip},https://reallyfreegeoip.org/json/{ip},https://hackmyip.com/api/lookup?ip={ip},https://get.geojs.io/v1/ip/geo/{ip}.json
#
# Only public routable addresses are sent; private/CGNAT/documentation/local peers never
# leave the host. Because the quotas are shared and small, the cache, negative cache
# and per-backend breakers below are required, not optional: lowering CACHE_TTL or
# raising NEGATIVE_TTL noticeably raises the 429 rate.
TELESRV_GEOIP_ENDPOINTS=
TELESRV_GEOIP_TIMEOUT=2s
TELESRV_GEOIP_CONCURRENCY=4
TELESRV_GEOIP_CACHE_TTL=24h
TELESRV_GEOIP_NEGATIVE_TTL=5m
TELESRV_GEOIP_CACHE_SIZE=4096
# Consecutive 429s from one backend before it is skipped entirely. Each backend has
# its own counter: one provider running dry never affects the others.
TELESRV_GEOIP_RATE_LIMIT_THRESHOLD=3
TELESRV_GEOIP_RATE_LIMIT_COOLDOWN=2m
# Consecutive timeouts/5xx before a backend is considered unreachable. Kept
# deliberately shorter than the rate-limit cooldown: a single network hiccup should
# not take a healthy provider offline for as long as a quota window lasts.
TELESRV_GEOIP_DOWN_THRESHOLD=2
TELESRV_GEOIP_DOWN_COOLDOWN=30s
## Seed Directories -- Data the server imports at startup (langpack, official gifts).
TELESRV_LANGPACK_SEED_DIR=data/langpack
TELESRV_OFFICIAL_GIFTS_DIR=data/official-gifts
## Star Gifts & Economy -- Expiry/auction sweeps and local-ledger rates. TON values never leave the built-in backend.
# Star Gift expiry/auction worker. TON values are handled by the local ledger;
# no wallet, Fragment or chain node endpoint is configured or contacted.
TELESRV_STARGIFT_SWEEP_INTERVAL=15s
TELESRV_STARGIFT_SWEEP_BATCH=1000
# Internal nanoton granted once per user on first local-ledger access.
TELESRV_STARGIFT_TON_STARTING_GRANT=10000000000
# Starting balance of the Stars local ledger, granted lazily on the first read
# (the granted flag keeps it idempotent and it applies to old and new accounts
# alike, so no backfill migration is needed). 0 turns the grant off.
TELESRV_STARS_STARTING_GRANT=1000
TELESRV_STARGIFT_TRANSFER_STARS=25
TELESRV_STARGIFT_DROP_DETAILS_STARS=25
TELESRV_STARGIFT_OFFER_MIN_STARS=1
TELESRV_STARGIFT_STARS_PROCEEDS_PERMILLE=1000
TELESRV_STARGIFT_TON_PROCEEDS_PERMILLE=1000
TELESRV_STARGIFT_EXPORT_DELAY=0s
TELESRV_STARGIFT_TRANSFER_DELAY=0s
TELESRV_STARGIFT_RESELL_DELAY=0s
TELESRV_STARGIFT_CRAFT_DELAY=0s
TELESRV_STARGIFT_CRAFT_CHANCE_PERMILLE=250
## In-App TON Wallet (TL Layer 230) -- ownership proofs, server-held keys, local-ledger balances.
# Private state directory: one 0600 JSON per account (challenges + verified
# address binding). Must be mode 0700. Leave empty to disable the wallet, which
# makes wallet.* answer WALLET_UNAVAILABLE.
TELESRV_WALLET_STATE_DIR=
# Explicit internal-ledger transfer extension. Requires an enabled wallet and
# a fresh, single-use account.getTmpPassword confirmation for every transfer.
# Also requires TELESRV_STARGIFT_TON_STARTING_GRANT=0 to prevent bonus farming.
# Chain sending and gasless remain unsupported.
TELESRV_WALLET_INTERNAL_TRANSFERS=false
# AES-256-GCM master key for wallet private keys. Generated on first boot when
# missing. Back this up with data/ -- losing it makes stored wallets unusable.
TELESRV_WALLET_KEY_FILE=data/wallet/keys.key
# Optional third-party TON provider for toncenter.performApiRequest. Empty means
# telesrv contacts no TON node at all; the RPC then answers
# WALLET_PROVIDER_UNAVAILABLE.
TELESRV_WALLET_TONCENTER_API_KEY=
## Account Rating -- Local admin-only composite rating: derivation, weights and the recompute worker.
# Local admin-only composite account rating. It is not projected into Telegram's
# userFull.stars_rating fields. Disabling it refuses local rating writes.
TELESRV_RATING_ENABLED=true
# A local rating increase is parked for this long before it becomes the visible
# admin level; a decrease always applies immediately. 0 applies every change at once.
TELESRV_RATING_PENDING_DELAY=24h
# Background recompute worker: the rating derives from signals owned by other
# subsystems, so freshness is a worker property rather than a write-path one.
TELESRV_RATING_RECOMPUTE_INTERVAL=15m
TELESRV_RATING_RECOMPUTE_BATCH=500
TELESRV_RATING_STALE_AFTER=6h
# Integer composite weights; the defaults below are exactly the shipped domain
# formula. Penalties are magnitudes that the formula subtracts, so every value is
# non-negative and a negative one fails startup.
TELESRV_RATING_WEIGHT_STARS_RECEIVED_PERMILLE=1000
TELESRV_RATING_WEIGHT_STARS_SPENT_PERMILLE=250
TELESRV_RATING_WEIGHT_MESSAGE_SENT=1
TELESRV_RATING_WEIGHT_ACCOUNT_AGE_DAY=2
TELESRV_RATING_WEIGHT_GIFT_RECEIVED=25
TELESRV_RATING_WEIGHT_MODERATION_CASE=150
TELESRV_RATING_WEIGHT_SCAM_PENALTY=5000
TELESRV_RATING_WEIGHT_FAKE_PENALTY=5000
# Upper bound of the activity component so activity alone cannot outweigh Stars
# and moderation; 0 leaves it uncapped.
TELESRV_RATING_ACTIVITY_CAP=5000
## Collectible Usernames -- Fragment-style NFT username minting and landing URLs.
## Crypto donations -- per-user deposit-to-Stars over custodial EVM addresses.
# Master switch, off by default and that default is deliberate: turning this on
# generates a custodial BIP39 wallet, stores it encrypted in the database, and
# starts a poller against every enabled chain's RPC endpoint. None of that should
# happen to a deployment that never asked for it. With it off, no wallet is
# created and no chain is contacted; the admin Donations page still shows the
# chain registry read-only.
TELESRV_DONATIONS_ENABLED=false
# Where the wallet's AES-256-GCM encryption key lives. Generated automatically
# the first time donations are enabled. Back this up exactly like the server
# RSA key: the encrypted seed in the database cannot be decrypted without it, so
# losing it means losing the wallet and anything deposited to it.
TELESRV_DONATION_WALLET_KEY_PATH=data/donation_wallet.key
# Overrides the key file above with a literal 64-hex-char key, for an operator
# who keeps it in a secrets manager instead of on disk.
TELESRV_DONATION_WALLET_KEY=
# How often each enabled chain is polled for new blocks.
TELESRV_DONATION_POLL_INTERVAL=5s
# Enabling the switch does not enable any chain. Each one is turned on in the
# admin panel (Economy > Donations) after its RPC endpoint is filled in, and a
# watcher only starts once the row is enabled *and* has a URL -- a seeded chain
# left with no endpoint logs one warning and is skipped rather than dialled.
# Landing URL recorded on a minted collectible (NFT) username when the mint
# command carries no explicit URL. Empty derives
# <TELESRV_PUBLIC_BASE_URL>/nft/username/<username>. A template may carry the
# {username} placeholder; without it the name is appended as the last path
# segment. No external marketplace is contacted.
TELESRV_COLLECTIBLE_USERNAME_URL_TEMPLATE=
## Verification -- Official @verifybot platform verification plus the durable broadcast fan-out.
# Official platform verification: applications filed through the built-in
# @verifybot and decided in the admin panel. An approval flips the platform
# verified flag on the target peer and nothing else; it is not the third-party
# bot verification icon. Disabling refuses every verification use case, while
# peers already carrying the badge keep it.
TELESRV_VERIFICATION_ENABLED=true
# Plain user accounts as verification subjects. Off by default: the official
# process verifies a public presence (bot, public channel, public supergroup).
TELESRV_VERIFICATION_ALLOW_USER_TARGETS=false
# How long an applicant must wait before filing the same target again after a
# rejection, measured from the decision so a slow review never shortens it.
# 0 disables the cooldown; must be 0..8760h.
TELESRV_VERIFICATION_REJECT_COOLDOWN=720h
# Applications one applicant may create per window. Either value 0 disables the
# budget; a positive limit requires a positive window.
TELESRV_VERIFICATION_APPLY_RATE_LIMIT=3
TELESRV_VERIFICATION_APPLY_RATE_WINDOW=24h
# @verifybot dialog rate per applicant, independent of how many applications are
# actually created. Either value 0 disables it.
TELESRV_VERIFICATION_BOT_RATE_LIMIT=30
TELESRV_VERIFICATION_BOT_RATE_WINDOW=1m
# Applicant notification worker. A decision commits with its outbox row, never
# with a message send, so delivery is a separate retrying cycle over durable
# rows. Interval must be positive; batch must be 1..500.
TELESRV_VERIFICATION_NOTIFY_INTERVAL=15s
TELESRV_VERIFICATION_NOTIFY_BATCH=50
TELESRV_BROADCAST_WORKER_INTERVAL=3s
TELESRV_BROADCAST_WORKER_LEASE=30s
TELESRV_BROADCAST_MATERIALIZE_BATCH=200
TELESRV_BROADCAST_DELIVERY_BATCH=50
# Applications one applicant may keep open at once; 0 disables the cap, maximum
# is 50.
TELESRV_VERIFICATION_MAX_ACTIVE_PER_USER=3
## Bot Verification (Third-Party) -- Verifier bots marking peers with their OWN icon and description.
# Third-party bot verification (core.telegram.org/api/bots/verification): a
# verifier bot marks peers with its OWN icon and description, which clients render
# before the name. This is NOT the platform checkmark above: the operator grants
# verifier status to a bot, and the two mechanisms never read each other's state.
# Disabling refuses every third-party mutation (grants, revocations, applications,
# icon catalogue edits) while the marks already granted keep rendering -- blanking
# one verifier's badges is what its per-verifier kill switch is for.
TELESRV_BOT_VERIFICATION_ENABLED=true
# Peers one verifier bot may mark. Verifier status is granted per deployment rather
# than earned per peer, so an unbounded verifier would be an unbounded badge
# printer. 0 disables the service bound and leaves only the storage bound, which is
# also the maximum accepted here (10000).
TELESRV_BOT_VERIFICATION_MAX_PER_VERIFIER=10000
# Verification applications one applicant may file per window, across all verifier
# bots. Either value 0 disables the budget; a positive limit requires a positive
# window. Looser than the official budget on purpose: a deployment can run several
# verifier companies, and filing with a second one is not a retry of the first.
TELESRV_BOT_VERIFICATION_REQUEST_RATE_LIMIT=5
TELESRV_BOT_VERIFICATION_REQUEST_RATE_WINDOW=24h
## Storage & Media -- The single permanent blob backend (localfs or S3) and the storage low-space guard.
# Exactly one permanent blob backend. localfs is the no-dependency default.
TELESRV_BLOB_BACKEND=localfs
TELESRV_BLOB_DIR=data/blobs
# S3/MinIO mode uses this directory only for transient upload parts and write spooling.
TELESRV_BLOB_STAGING_DIR=data/blob-staging
# TELESRV_S3_ENDPOINT=minio.internal:9000
# TELESRV_S3_REGION=us-east-1
# TELESRV_S3_BUCKET=telesrv-media
# TELESRV_S3_ACCESS_KEY_ID=
# TELESRV_S3_SECRET_ACCESS_KEY=
# TELESRV_S3_USE_SSL=true
# TELESRV_S3_PATH_STYLE=false
# TELESRV_S3_CREATE_BUCKET=false
# Capacity checks are initialized synchronously before media writes are exposed.
# In S3 mode MIN_FREE_BYTES protects local upload/spool space; MAX_TOTAL_BYTES is
# an optional budget over unique S3 object keys tracked by file_blobs (0 disables it).
TELESRV_STORAGE_LOW_SPACE_GUARD_ENABLE=true
TELESRV_STORAGE_MIN_FREE_BYTES=1073741824
TELESRV_STORAGE_MAX_TOTAL_BYTES=0
TELESRV_STORAGE_USAGE_REFRESH_INTERVAL=1m
# Per-user budget for uploads that are still being assembled: the bytes and the
# number of not-yet-assembled file_ids one account may have in flight. 0 or
# less means unlimited.
TELESRV_UPLOAD_INFLIGHT_MAX_BYTES=4194304000
TELESRV_UPLOAD_INFLIGHT_MAX_FILES=64
## Media Seed Directories -- Optional startup imports: stickers, @gif catalogue, Premium preview media.
TELESRV_STICKER_SEED_DIR=data/sticker-seed
# Optional curated @gif startup import directory (.gif/.mp4, max 50 total catalog entries).
TELESRV_GIF_SEED_DIR=data/gifs
# Optional Premium feature-preview media export. Missing directory keeps the
# no-video fallback; an existing but incomplete/invalid directory fails startup.
TELESRV_PREMIUM_PROMO_SEED_DIR=data/premium-promo
## Public Web Listener -- Serves /<username>, profile avatars, sticker/custom emoji sets and shared folders.
# Optional public-link Web listener for /<username>, profile avatars,
# sticker/custom emoji sets, and shared folders. This is a host:port bind
# address without a URL scheme. It is not replaced by TELESRV_PUBLIC_BASE_URL.
# Production should keep it on loopback and reverse-proxy the documented routes
# through nginx; public canonical URLs use TELESRV_PUBLIC_BASE_URL.
TELESRV_PUBLIC_LINK_WEB_ADDR=127.0.0.1:2401
## Development Checkout -- Local dev-only Stars/Premium checkout.
# Local dev/fiat Stars/Premium checkout (/payments/dev-stars). Denied by
# default so production never mints Stars or Premium without a real XTR
# payment; enable only in dev/test environments.
TELESRV_ALLOW_DEV_PAYMENTS=false
## Telegram Login (OpenID Connect) -- Self-hosted "Log in with Telegram" for third-party sites.
# Self-hosted Telegram Login / OpenID Connect. The provider is mounted on the
# public-link listener above. Keep disabled until all three local key files
# have been generated with `go run ./cmd/telegramloginkeygen -mode init`.
TELESRV_TELEGRAM_LOGIN_ENABLE=false
TELESRV_TELEGRAM_LOGIN_ISSUER=https://telesrv.net
# Set true to permit an HTTP issuer and HTTP registered origins/redirect URIs
# on any hostname or IP address. HTTPS remains the default when false.
TELESRV_TELEGRAM_LOGIN_ALLOW_HTTP=false
TELESRV_TELEGRAM_LOGIN_SIGNING_KEYS_FILE=data/telegram-login/signing-keys.json
TELESRV_TELEGRAM_LOGIN_CODE_KEYS_FILE=data/telegram-login/code-keys.json
TELESRV_TELEGRAM_LOGIN_SECRET_PEPPER_FILE=data/telegram-login/client-secret-pepper
TELESRV_TELEGRAM_LOGIN_REQUEST_TTL=5m
TELESRV_TELEGRAM_LOGIN_CODE_TTL=2m
TELESRV_TELEGRAM_LOGIN_ID_TOKEN_TTL=1h
# Trust only the loopback nginx hop in the documented single-host deployment.
TELESRV_TELEGRAM_LOGIN_TRUSTED_PROXY_CIDRS=127.0.0.1/32,::1/128
TELESRV_TELEGRAM_LOGIN_RETENTION=168h
TELESRV_TELEGRAM_LOGIN_SWEEP_INTERVAL=5m
TELESRV_TELEGRAM_LOGIN_SWEEP_BATCH=500
## AI & Translation -- AI-assisted composing and chat/message translation, plus optional external providers.
# AI compose for TDesktop/Android input box rewrite/polish.
# The local provider is deterministic and does not call external services.
TELESRV_AI_ENABLED=true
TELESRV_AI_PROVIDERS=local
TELESRV_AI_TIMEOUT=15s
TELESRV_AI_RATE_LIMIT=20
TELESRV_AI_RATE_WINDOW=1m
TELESRV_AI_LOG_CONTENT=false
# Chat/message translation reuses the remote providers declared above. The
# deterministic "local" AI provider is excluded because it cannot translate.
# Leave TRANSLATION_PROVIDERS empty to use all configured remote AI providers,
# or provide a comma-separated subset such as "openai,gemini".
TELESRV_TRANSLATION_ENABLED=true
TELESRV_TRANSLATION_PROVIDERS=
TELESRV_TRANSLATION_TIMEOUT=15s
# Counts translated text items, not RPC envelopes (one RPC may contain 20).
TELESRV_TRANSLATION_RATE_LIMIT=60
TELESRV_TRANSLATION_RATE_WINDOW=1m
# External providers are optional. Keep API keys in TELESRV_* variables here;
# the loader rejects non-TELESRV keys from .env files by design.
# TELESRV_AI_OPENAI_KIND=openai_responses
# TELESRV_AI_OPENAI_API_KEY=
# TELESRV_AI_OPENAI_MODEL=
# TELESRV_AI_OPENAI_BASE_URL=
# TELESRV_AI_OPENAI_MAX_OUTPUT_TOKENS=1024
# TELESRV_AI_OPENAI_TEMPERATURE=0.2
# TELESRV_AI_OPENAI_OMIT_TEMPERATURE=false
# TELESRV_AI_OPENAI_THINKING=
# TELESRV_AI_GEMINI_KIND=gemini
# TELESRV_AI_GEMINI_API_KEY=
# TELESRV_AI_GEMINI_MODEL=
# TELESRV_AI_GEMINI_TEMPERATURE=0.2
# TELESRV_AI_ANTHROPIC_KIND=anthropic
# TELESRV_AI_ANTHROPIC_API_KEY=
# TELESRV_AI_ANTHROPIC_MODEL=
# Kimi/Moonshot can be used as an OpenAI-compatible Chat Completions provider.
# TELESRV_AI_PROVIDERS=kimi,local
# TELESRV_AI_KIMI_KIND=openai_chat
# TELESRV_AI_KIMI_API_KEY=
# TELESRV_AI_KIMI_BASE_URL=https://api.moonshot.cn/v1
# TELESRV_AI_KIMI_MODEL=kimi-k2.6
# TELESRV_AI_KIMI_THINKING=disabled
# TELESRV_AI_KIMI_TEMPERATURE=0.6
# Business automation reply provider:
# echo (default/empty), template/quick_reply/quick-reply, or
# ai/compose_ai/ai_compose/aicompose/kimi to reuse TELESRV_AI_PROVIDERS.
# Custom provider names such as "ollama" are selected through TELESRV_AI_PROVIDERS;
# use TELESRV_BUSINESS_AI_PROVIDER=ai for those.
TELESRV_BUSINESS_AI_PROVIDER=echo
# Voice Transcribe (ASR server)
# TELESRV_ASR_URL=
# TELESRV_ASR_TIMEOUT=