How flowseal/tg-ws-proxy works
TG WS Proxy is a local MTProto proxy for Telegram Desktop: it accepts Telegram’s local proxy connection, identifies the destination DC, and relays encrypted traffic over WebSocket, with Cloudflare and direct-TCP fallback options. The tray application configures and manages that runtime and offers diagnostics and update checks. The main routing and fallback paths are evidenced by the README and proxy entry-point references; unsampled modules are included where their roles are documented or named, but their internal call links are omitted when not shown.
Main entry points: tg_ws_proxy.py MTProto listener · tray_common.py Tray controls · settings_form.py Settings editor · cf_h2.py Cloudflare HTTP/2
Components 26
Tray application
- Tray controls
utils/tray_common.py - Platform launchers
windows.py - Settings editor
ui/settings_form.py - Settings dialog
ui/settings_dialog.py - Tray widgets
ui/ctk_tray_ui.py - Theme and controls
ui/ctk_theme.py
Proxy runtime
- MTProto listener
proxy/tg_ws_proxy.py - Traffic bridge
proxy/bridge.py - AES obfuscation
proxy/_aes.py - Fake TLS
proxy/fake_tls.py
Transport routing
- Telegram WebSocket
proxy/raw_websocket.py - Fallback routing
proxy/tg_ws_proxy.py - Cloudflare HTTP/2
proxy/cf_h2.py - HTTP/2 transport
proxy/h2_transport.py - WebSocket pool
proxy/pool.py - Domain balancer
proxy/balancer.py
Configuration and status
- Proxy configuration
proxy/config.py - Network diagnostics
proxy/network_debug.py - Traffic statistics
proxy/stats.py - Tray config and logs
utils/tray_common.py - Update checker
utils/update_check.py - Translations
ui/i18n/__init__.py
Other components
- Telegram Desktop
- Telegram DC
- Cloudflare proxy
- Direct TCP
Connections 26
- Telegram Desktop → MTProto listener: connects locally
- MTProto listener → Traffic bridge: dispatches relay
proxy/tg_ws_proxy.py - MTProto listener → Telegram WebSocket: opens WebSocket
proxy/tg_ws_proxy.py - MTProto listener → Fallback routing: routes when unavailable
proxy/tg_ws_proxy.py - Fallback routing → Cloudflare HTTP/2: uses H2 pool
proxy/tg_ws_proxy.py - Fallback routing → Direct TCP: falls back to TCP
- Telegram WebSocket → Telegram DC: relays encrypted traffic
- Cloudflare HTTP/2 → HTTP/2 transport: uses transport
proxy/cf_h2.py - Cloudflare HTTP/2 → Cloudflare proxy: sends H2 requests
- MTProto listener → WebSocket pool: reuses connections
proxy/tg_ws_proxy.py - WebSocket pool → Telegram WebSocket: pools WebSockets
proxy/pool.py - Proxy configuration → Domain balancer: updates domains
proxy/config.py - Tray controls → MTProto listener: starts and restarts
utils/tray_common.py - Tray controls → Tray config and logs: loads and saves
utils/tray_common.py - Tray controls → Settings dialog: opens settings
utils/tray_common.py - Settings dialog → Settings editor: builds form
ui/settings_dialog.py - Settings editor → Tray widgets: uses widgets
ui/ctk_tray_ui.py - Settings editor → Update checker: offers update check
ui/settings_form.py - Tray controls → Update checker: checks releases
utils/tray_common.py - Tray controls → Proxy configuration: applies settings
utils/tray_common.py - MTProto listener → Proxy configuration: reads routing config
proxy/tg_ws_proxy.py - Traffic bridge → Traffic statistics: records traffic
proxy/bridge.py - MTProto listener → Fake TLS: dispatches TLS mode
proxy/tg_ws_proxy.py - Settings editor → Translations: translates labels
ui/settings_form.py - Platform launchers → Tray controls: uses common tray
windows.py - Tray widgets → Theme and controls: uses styling
ui/ctk_tray_ui.py