perf: sync protocol and core hardening updates

This commit is contained in:
A 2026-07-11 19:48:26 +08:00
parent 152fed3b87
commit 4390ebf5a9
283 changed files with 29231 additions and 2295 deletions

View file

@ -7,6 +7,31 @@ TELESRV_DC=2
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
# 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=8192
TELESRV_MTPROTO_RPC_GLOBAL_MAX_BYTES=536870912
# 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
# Concurrent encrypted wire/codec/obfuscation scratch (shared bounded pool, not per connection).
TELESRV_MTPROTO_OUTBOUND_WRITE_GLOBAL_MAX_BYTES=536870912
# Optional login-email verification. When enabled, accounts with a confirmed
# login email receive login codes by email; REQUIRE_SETUP also forces new/legacy
@ -56,6 +81,21 @@ TELESRV_REDIS_ADDR=127.0.0.1:6399
TELESRV_REDIS_PASSWORD=
TELESRV_REDIS_DB=0
# Bounded retention/GC. User/channel update rows are only pruned behind protocol-safe floors.
TELESRV_UPDATE_EVENT_RETENTION=168h
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
# 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
# Optional. Enables Mapbox-backed map previews and TDesktop map picker config.
TELESRV_MAPBOX_TOKEN=
TELESRV_MAPTILE_CACHE_DIR=data/maptiles