mirror of
https://github.com/telemt/telemt.git
synced 2026-04-14 17:14:09 +03:00
Merge branch 'main' into main
This commit is contained in:
@@ -3,50 +3,39 @@
|
|||||||
## Purpose
|
## Purpose
|
||||||
|
|
||||||
**Telemt exists to solve technical problems.**
|
**Telemt exists to solve technical problems.**
|
||||||
|
- Telemt is open to contributors who want to learn, improve and build meaningful systems together.
|
||||||
|
- It is a place for building, testing, reasoning, documenting, and improving systems.
|
||||||
|
- Discussions that advance this work are in scope, discussions that divert it are not.
|
||||||
|
- Technology has consequences, responsibility is inherent.
|
||||||
|
|
||||||
Telemt is open to contributors who want to learn, improve and build meaningful systems together.
|
> **Absicht bestimmt die Form**
|
||||||
|
|
||||||
It is a place for building, testing, reasoning, documenting, and improving systems.
|
> Purpose defines form
|
||||||
|
|
||||||
Discussions that advance this work are in scope. Discussions that divert it are not.
|
|
||||||
|
|
||||||
Technology has consequences. Responsibility is inherent.
|
|
||||||
|
|
||||||
> **Zweck bestimmt die Form.**
|
|
||||||
|
|
||||||
> Purpose defines form.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Principles
|
## Principles
|
||||||
|
|
||||||
* **Technical over emotional**
|
* **Technical over emotional**
|
||||||
|
- Arguments are grounded in data, logs, reproducible cases, or clear reasoning.
|
||||||
Arguments are grounded in data, logs, reproducible cases, or clear reasoning.
|
|
||||||
|
|
||||||
* **Clarity over noise**
|
* **Clarity over noise**
|
||||||
|
- Communication is structured, concise, and relevant.
|
||||||
Communication is structured, concise, and relevant.
|
|
||||||
|
|
||||||
* **Openness with standards**
|
* **Openness with standards**
|
||||||
|
- Participation is open. The work remains disciplined.
|
||||||
Participation is open. The work remains disciplined.
|
|
||||||
|
|
||||||
* **Independence of judgment**
|
* **Independence of judgment**
|
||||||
|
- Claims are evaluated on technical merit, not affiliation or posture.
|
||||||
Claims are evaluated on technical merit, not affiliation or posture.
|
|
||||||
|
|
||||||
* **Responsibility over capability**
|
* **Responsibility over capability**
|
||||||
|
- Capability does not justify careless use.
|
||||||
Capability does not justify careless use.
|
|
||||||
|
|
||||||
* **Cooperation over friction**
|
* **Cooperation over friction**
|
||||||
|
- Progress depends on coordination, mutual support, and honest review.
|
||||||
Progress depends on coordination, mutual support, and honest review.
|
|
||||||
|
|
||||||
* **Good intent, rigorous method**
|
* **Good intent, rigorous method**
|
||||||
|
- Assume good intent, but require rigor.
|
||||||
Assume good intent, but require rigor.
|
|
||||||
|
|
||||||
> **Aussagen gelten nach ihrer Begründung.**
|
> **Aussagen gelten nach ihrer Begründung.**
|
||||||
|
|
||||||
@@ -68,7 +57,9 @@ Participants are expected to:
|
|||||||
|
|
||||||
Precision is learned.
|
Precision is learned.
|
||||||
|
|
||||||
New contributors are welcome. They are expected to grow into these standards. Existing contributors are expected to make that growth possible.
|
- New contributors are welcome
|
||||||
|
- They are expected to grow into these standards
|
||||||
|
- Existing contributors are expected to make that growth possible
|
||||||
|
|
||||||
> **Wer behauptet, belegt.**
|
> **Wer behauptet, belegt.**
|
||||||
|
|
||||||
@@ -112,7 +103,7 @@ Security is both technical and behavioral.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 6. Openness
|
## Openness
|
||||||
|
|
||||||
Telemt is open to contributors of different backgrounds, experience levels, and working styles.
|
Telemt is open to contributors of different backgrounds, experience levels, and working styles.
|
||||||
|
|
||||||
@@ -148,10 +139,9 @@ Judgment should be exercised with restraint, consistency, and institutional resp
|
|||||||
|
|
||||||
All decisions are expected to serve the durability, clarity, and integrity of Telemt.
|
All decisions are expected to serve the durability, clarity, and integrity of Telemt.
|
||||||
|
|
||||||
> **Ordnung ist Voraussetzung der Funktion.**
|
> **Klarheit vor Zustimmung - Bestand vor Beifall**
|
||||||
|
|
||||||
> Order is the precondition of function.
|
|
||||||
|
|
||||||
|
> Clarity above approval - substantiality before success
|
||||||
---
|
---
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
@@ -171,42 +161,41 @@ Actions are taken to maintain function, continuity, and signal quality.
|
|||||||
|
|
||||||
## Final
|
## Final
|
||||||
|
|
||||||
Telemt is built on discipline, structure, and shared intent.
|
**Telemt is built on discipline, structure, and shared intent**
|
||||||
- Signal over noise.
|
- Signal over noise
|
||||||
- Facts over opinion.
|
- Facts over opinion
|
||||||
- Systems over rhetoric.
|
- Systems over rhetoric
|
||||||
|
- Work is collective
|
||||||
|
- Outcomes are shared
|
||||||
|
- Responsibility is distributed
|
||||||
|
- Precision is learned
|
||||||
|
- Rigor is expected
|
||||||
|
- Help is part of the work
|
||||||
|
|
||||||
- Work is collective.
|
> **Ordnung ist Voraussetzung der Freiheit**
|
||||||
- Outcomes are shared.
|
|
||||||
- Responsibility is distributed.
|
|
||||||
|
|
||||||
- Precision is learned.
|
- If you contribute — contribute with care
|
||||||
- Rigor is expected.
|
- If you speak — speak with substance
|
||||||
- Help is part of the work.
|
- If you engage — engage constructively
|
||||||
|
|
||||||
> **Ordnung ist Voraussetzung der Freiheit.**
|
|
||||||
|
|
||||||
- If you contribute — contribute with care.
|
|
||||||
- If you speak — speak with substance.
|
|
||||||
- If you engage — engage constructively.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## After All
|
## After All
|
||||||
|
|
||||||
Systems outlive intentions.
|
Systems outlive intentions
|
||||||
- What is built will be used.
|
- What is built will be used
|
||||||
- What is released will propagate.
|
- What is released will propagate
|
||||||
- What is maintained will define the future state.
|
- What is maintained will define the future state
|
||||||
|
|
||||||
There is no neutral infrastructure, only infrastructure shaped well or poorly.
|
There is no neutral infrastructure, only infrastructure shaped well or poorly
|
||||||
|
|
||||||
> **Jedes System trägt Verantwortung.**
|
> **Ordnung → Umsetzung → Ergebnis**
|
||||||
|
|
||||||
> Every system carries responsibility.
|
> Order → Implementation → Result
|
||||||
|
|
||||||
- Stability requires discipline.
|
- Stability requires discipline
|
||||||
- Freedom requires structure.
|
- Freedom requires structure
|
||||||
- Trust requires honesty.
|
- Trust requires honesty
|
||||||
|
|
||||||
|
In the end: the system reflects its contributors
|
||||||
|
|
||||||
In the end: the system reflects its contributors.
|
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -1,30 +1,29 @@
|
|||||||
# Telemt - MTProxy on Rust + Tokio
|
# Telemt - MTProxy on Rust + Tokio
|
||||||
|
|
||||||
|
   [](https://t.me/telemtrs)
|
||||||
|
|
||||||
***Löst Probleme, bevor andere überhaupt wissen, dass sie existieren*** / ***It solves problems before others even realize they exist***
|
***Löst Probleme, bevor andere überhaupt wissen, dass sie existieren*** / ***It solves problems before others even realize they exist***
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
>
|
>
|
||||||
> Fixed TLS ClientHello is now available:
|
> Fixed TLS ClientHello is now available in official clients for Desktop / Android / iOS
|
||||||
> - in **Telegram Desktop** starting from version **6.7.2**
|
|
||||||
> - in **Telegram Android Client** starting from version **12.6.4**
|
|
||||||
> - **release for iOS is "work in progress"**
|
|
||||||
>
|
>
|
||||||
> To work with EE-MTProxy, please update your client!
|
> To work with EE-MTProxy, please update your client!
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://t.me/telemtrs">
|
<a href="https://t.me/telemtrs">
|
||||||
<img src="/docs/assets/telegram_button.svg" width="200"/>
|
<img src="/docs/assets/telegram_button.svg" width="150"/>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
**Telemt** is a fast, secure, and feature-rich server written in Rust: it fully implements the official Telegram proxy algo and adds many production-ready improvements such as:
|
**Telemt** is a fast, secure, and feature-rich server written in Rust: it fully implements the official Telegram proxy algo and adds many production-ready improvements
|
||||||
- [ME Pool + Reader/Writer + Registry + Refill + Adaptive Floor + Trio-State + Generation Lifecycle](https://github.com/telemt/telemt/blob/main/docs/Architecture/Model/MODEL.en.md);
|
|
||||||
- [Full-covered API w/ management](https://github.com/telemt/telemt/blob/main/docs/Architecture/API/API.md);
|
|
||||||
- Anti-Replay on Sliding Window;
|
|
||||||
- Prometheus-format Metrics;
|
|
||||||
- TLS-Fronting and TCP-Splicing for masking from "prying" eyes.
|
|
||||||
|
|
||||||

|
### One-command Install and Update
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/telemt/telemt/main/install.sh | sh
|
||||||
|
```
|
||||||
|
- [Quick Start Guide](docs/Quick_start/QUICK_START_GUIDE.en.md)
|
||||||
|
- [Инструкция по быстрому запуску](docs/Quick_start/QUICK_START_GUIDE.ru.md)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
Our implementation of **TLS-fronting** is one of the most deeply debugged, focused, advanced and *almost* **"behaviorally consistent to real"**: we are confident we have it right - [see evidence on our validation and traces](docs/FAQ.en.md#recognizability-for-dpi-and-crawler)
|
Our implementation of **TLS-fronting** is one of the most deeply debugged, focused, advanced and *almost* **"behaviorally consistent to real"**: we are confident we have it right - [see evidence on our validation and traces](docs/FAQ.en.md#recognizability-for-dpi-and-crawler)
|
||||||
@@ -41,28 +40,17 @@ Our ***Middle-End Pool*** is fastest by design in standard scenarios, compared t
|
|||||||
- Graceful shutdown on Ctrl+C;
|
- Graceful shutdown on Ctrl+C;
|
||||||
- Extensive logging via `trace` and `debug` with `RUST_LOG` method.
|
- Extensive logging via `trace` and `debug` with `RUST_LOG` method.
|
||||||
|
|
||||||
## One-command installation (update on re-ru)
|
|
||||||
```bash
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/telemt/telemt/main/install.sh | sh
|
|
||||||
```
|
|
||||||
See more in the [Quick Start Guide](docs/Quick_start/QUICK_START_GUIDE.en.md).
|
|
||||||
|
|
||||||
# GOTO
|
|
||||||
- [FAQ](#faq)
|
|
||||||
- [Architecture](docs/Architecture)
|
|
||||||
- [Quick Start Guide](#quick-start-guide)
|
|
||||||
- [Config parameters](docs/Config_params)
|
|
||||||
- [Build](#build)
|
|
||||||
- [Why Rust?](#why-rust)
|
|
||||||
|
|
||||||
## Quick Start Guide
|
|
||||||
- [Quick Start Guide RU](docs/Quick_start/QUICK_START_GUIDE.ru.md)
|
|
||||||
- [Quick Start Guide EN](docs/Quick_start/QUICK_START_GUIDE.en.md)
|
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
- [FAQ RU](docs/FAQ.ru.md)
|
- [FAQ RU](docs/FAQ.ru.md)
|
||||||
- [FAQ EN](docs/FAQ.en.md)
|
- [FAQ EN](docs/FAQ.en.md)
|
||||||
|
|
||||||
|
# Learn more about Telemt
|
||||||
|
- [Our Architecture](docs/Architecture)
|
||||||
|
- [All Config Options](docs/Config_params)
|
||||||
|
- [How to build your own Telemt?](#build)
|
||||||
|
- [Running on BSD](docs/Quick_start/OPENBSD_QUICK_START_GUIDE.en.md)
|
||||||
|
- [Why Rust?](#why-rust)
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
```bash
|
```bash
|
||||||
# Cloning repo
|
# Cloning repo
|
||||||
@@ -83,15 +71,11 @@ chmod +x /bin/telemt
|
|||||||
telemt config.toml
|
telemt config.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
### OpenBSD
|
|
||||||
- Build and service setup guide: [OpenBSD Guide (EN)](docs/Quick_start/OPENBSD_QUICK_START_GUIDE.en.md)
|
|
||||||
- Example rc.d script: [contrib/openbsd/telemt.rcd](contrib/openbsd/telemt.rcd)
|
|
||||||
- Status: OpenBSD sandbox hardening with `pledge(2)` and `unveil(2)` is not implemented yet.
|
|
||||||
|
|
||||||
|
|
||||||
## Why Rust?
|
## Why Rust?
|
||||||
- Long-running reliability and idempotent behavior
|
- Long-running reliability and idempotent behavior
|
||||||
- Rust's deterministic resource management - RAII
|
- Rust's deterministic resource management - RAII
|
||||||
- No garbage collector
|
- No garbage collector
|
||||||
- Memory safety and reduced attack surface
|
- Memory safety and reduced attack surface
|
||||||
- Tokio's asynchronous architecture
|
- Tokio's asynchronous architecture
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
48
README.ru.md
48
README.ru.md
@@ -1,32 +1,32 @@
|
|||||||
# Telemt — MTProxy на Rust + Tokio
|
# Telemt — MTProxy на Rust + Tokio
|
||||||
|
|
||||||
|
   [](https://t.me/telemtrs)
|
||||||
|
|
||||||
***Решает проблемы раньше, чем другие узнают об их существовании***
|
***Решает проблемы раньше, чем другие узнают об их существовании***
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
>
|
>
|
||||||
> Исправленный TLS ClientHello доступен:
|
> Исправленный TLS ClientHello доступен в Telegram для настольных ПК, Android и iOS.
|
||||||
> - в **Telegram Desktop** начиная с версии **6.7.2**
|
|
||||||
> - в **Telegram Android** начиная с версии **12.6.4**
|
|
||||||
> - **официальный релиз для iOS находится в процессе разработки**.
|
|
||||||
>
|
>
|
||||||
> Для работы с EE-MTProxy обновите клиент!
|
> Пожалуйста, обновите клиентское приложение для работы с EE-MTProxy.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://t.me/telemtrs">
|
<a href="https://t.me/telemtrs">
|
||||||
<img src="/docs/assets/telegram_button.svg" width="200"/>
|
<img src="/docs/assets/telegram_button.svg" width="150"/>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
**Telemt** — это быстрый, безопасный и функциональный сервер, написанный на Rust. Он полностью реализует официальный алгоритм прокси Telegram и добавляет множество улучшений для продакшена:
|
**Telemt** — это быстрый, безопасный и функциональный сервер, написанный на Rust. Он полностью реализует официальный алгоритм прокси Telegram и добавляет множество улучшений для продакшена:
|
||||||
- [ME Pool + Reader/Writer + Registry + Refill + Adaptive Floor + Trio-State + жизненный цикл генераций](https://github.com/telemt/telemt/blob/main/docs/Architecture/Model/MODEL.en.md);
|
|
||||||
- [Полноценный API с управлением](https://github.com/telemt/telemt/blob/main/docs/Architecture/API/API.md);
|
|
||||||
- Защита от повторных атак (Anti-Replay on Sliding Window);
|
|
||||||
- Метрики в формате Prometheus;
|
|
||||||
- TLS-fronting и TCP-splicing для маскировки от DPI.
|
|
||||||
|
|
||||||

|
## Установка и обновление одной командой
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/telemt/telemt/main/install.sh | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- [Инструкция по быстрому запуску](docs/Quick_start/QUICK_START_GUIDE.ru.md)
|
||||||
|
- [Quick Start Guide](docs/Quick_start/QUICK_START_GUIDE.en.md)
|
||||||
|
|
||||||
## Особенности
|
|
||||||
Реализация **TLS-fronting** максимально приближена к поведению реального HTTPS-трафика (подробнее - [FAQ](docs/FAQ.ru.md#распознаваемость-для-dpi-и-сканеров)).
|
Реализация **TLS-fronting** максимально приближена к поведению реального HTTPS-трафика (подробнее - [FAQ](docs/FAQ.ru.md#распознаваемость-для-dpi-и-сканеров)).
|
||||||
|
|
||||||
***Middle-End Pool*** оптимизирован для высокой производительности.
|
***Middle-End Pool*** оптимизирован для высокой производительности.
|
||||||
@@ -41,27 +41,13 @@
|
|||||||
- Корректное завершение работы (Ctrl+C);
|
- Корректное завершение работы (Ctrl+C);
|
||||||
- Подробное логирование через `trace` и `debug`.
|
- Подробное логирование через `trace` и `debug`.
|
||||||
|
|
||||||
|
# Подробнее о Telemt
|
||||||
## Быстрая установка (обновление при повторном запуске)
|
|
||||||
```bash
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/telemt/telemt/main/install.sh | sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Подробнее об установке в [Quick Start Guide](docs/Quick_start/QUICK_START_GUIDE.ru.md).
|
|
||||||
|
|
||||||
# Навигация
|
|
||||||
- [FAQ](#faq)
|
- [FAQ](#faq)
|
||||||
- [Архитектура](docs/Architecture)
|
- [Архитектура](docs/Architecture)
|
||||||
- [Быстрый старт](#quick-start-guide)
|
|
||||||
- [Параметры конфигурационного файла](docs/Config_params)
|
- [Параметры конфигурационного файла](docs/Config_params)
|
||||||
- [Сборка](#build)
|
- [Сборка](#build)
|
||||||
|
- [Установка на BSD](#%D1%83%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0-%D0%BD%D0%B0-bsd)
|
||||||
- [Почему Rust?](#why-rust)
|
- [Почему Rust?](#why-rust)
|
||||||
- [Известные проблемы](#issues)
|
|
||||||
- [Планы](#roadmap)
|
|
||||||
|
|
||||||
## Быстрый старт
|
|
||||||
- [Quick Start Guide RU](docs/Quick_start/QUICK_START_GUIDE.ru.md)
|
|
||||||
- [Quick Start Guide EN](docs/Quick_start/QUICK_START_GUIDE.en.md)
|
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
- [FAQ RU](docs/FAQ.ru.md)
|
- [FAQ RU](docs/FAQ.ru.md)
|
||||||
@@ -87,7 +73,7 @@ chmod +x /bin/telemt
|
|||||||
telemt config.toml
|
telemt config.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
### OpenBSD
|
## Установка на BSD
|
||||||
- Руководство по сборке и настройке на английском языке [OpenBSD Guide (EN)](docs/Quick_start/OPENBSD_QUICK_START_GUIDE.en.md);
|
- Руководство по сборке и настройке на английском языке [OpenBSD Guide (EN)](docs/Quick_start/OPENBSD_QUICK_START_GUIDE.en.md);
|
||||||
- Пример rc.d скрипта: [contrib/openbsd/telemt.rcd](contrib/openbsd/telemt.rcd);
|
- Пример rc.d скрипта: [contrib/openbsd/telemt.rcd](contrib/openbsd/telemt.rcd);
|
||||||
- Поддержка sandbox с `pledge(2)` и `unveil(2)` пока не реализована.
|
- Поддержка sandbox с `pledge(2)` и `unveil(2)` пока не реализована.
|
||||||
@@ -98,3 +84,5 @@ telemt config.toml
|
|||||||
- Отсутствие сборщика мусора;
|
- Отсутствие сборщика мусора;
|
||||||
- Безопасность памяти;
|
- Безопасность памяти;
|
||||||
- Асинхронная архитектура Tokio.
|
- Асинхронная архитектура Tokio.
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
@@ -9,11 +9,11 @@ services:
|
|||||||
- "127.0.0.1:9090:9090"
|
- "127.0.0.1:9090:9090"
|
||||||
- "127.0.0.1:9091:9091"
|
- "127.0.0.1:9091:9091"
|
||||||
# Allow caching 'proxy-secret' in read-only container
|
# Allow caching 'proxy-secret' in read-only container
|
||||||
working_dir: /run/telemt
|
working_dir: /etc/telemt
|
||||||
volumes:
|
volumes:
|
||||||
- ./config.toml:/run/telemt/config.toml:ro
|
- ./config.toml:/etc/telemt/config.toml:ro
|
||||||
tmpfs:
|
tmpfs:
|
||||||
- /run/telemt:rw,mode=1777,size=1m
|
- /etc/telemt:rw,mode=1777,size=4m
|
||||||
environment:
|
environment:
|
||||||
- RUST_LOG=info
|
- RUST_LOG=info
|
||||||
# Uncomment this line if you want to use host network for IPv6, but bridge is default and usually better
|
# Uncomment this line if you want to use host network for IPv6, but bridge is default and usually better
|
||||||
@@ -21,11 +21,12 @@ services:
|
|||||||
cap_drop:
|
cap_drop:
|
||||||
- ALL
|
- ALL
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_BIND_SERVICE # allow binding to port 443
|
- NET_BIND_SERVICE
|
||||||
|
- NET_ADMIN
|
||||||
read_only: true
|
read_only: true
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
ulimits:
|
ulimits:
|
||||||
nofile:
|
nofile:
|
||||||
soft: 65536
|
soft: 65536
|
||||||
hard: 65536
|
hard: 262144
|
||||||
|
|||||||
141
docs/Advanced_settings/HIGH_LOAD.en.md
Normal file
141
docs/Advanced_settings/HIGH_LOAD.en.md
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
# High-Load Configuration & Tuning Guide
|
||||||
|
When deploying Telemt under high-traffic load (tens or hundreds of thousands of concurrent connections), the standard OS network stack limits can lead to packet drops, high CPU context switching, and connection failures. This guide covers Linux kernel tuning, hardware configuration, and architecture optimizations required to prepare the server for high-load scenarios.
|
||||||
|
|
||||||
|
---
|
||||||
|
## 1. System Limits & File Descriptors
|
||||||
|
Every TCP connection requires a file descriptor. At 100k connections, standard Linux limits (often 1024 or 65535) will be exhausted immediately.
|
||||||
|
### System-Wide Limits (`sysctl`)
|
||||||
|
Increase the global file descriptor limit in `/etc/sysctl.conf`:
|
||||||
|
```ini
|
||||||
|
fs.file-max = 2097152
|
||||||
|
fs.nr_open = 2097152
|
||||||
|
```
|
||||||
|
### User-Level Limits (`limits.conf`)
|
||||||
|
Edit `/etc/security/limits.conf` to allow the telemt (or proxy) user to allocate them:
|
||||||
|
```conf
|
||||||
|
* soft nofile 1048576
|
||||||
|
* hard nofile 1048576
|
||||||
|
root soft nofile 1048576
|
||||||
|
root hard nofile 1048576
|
||||||
|
```
|
||||||
|
### Systemd / Docker Overrides
|
||||||
|
If using **Systemd**, add to your `telemt.service`:
|
||||||
|
```ini
|
||||||
|
[Service]
|
||||||
|
LimitNOFILE=1048576
|
||||||
|
LimitNPROC=65535
|
||||||
|
TasksMax=infinity
|
||||||
|
```
|
||||||
|
If using **Docker**, configure `ulimits` in `docker-compose.yaml`:
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
telemt:
|
||||||
|
ulimits:
|
||||||
|
nofile:
|
||||||
|
soft: 1048576
|
||||||
|
hard: 1048576
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## 2. Kernel Network Stack Tuning (`sysctl`)
|
||||||
|
Create a dedicated file `/etc/sysctl.d/99-telemt-highload.conf` and apply it via `sysctl -p /etc/sysctl.d/99-telemt-highload.conf`.
|
||||||
|
### 2.1 Connection Queues & SYN Flood Protection
|
||||||
|
Increase the size of accept queues to absorb sudden connection spikes (bursts) and mitigate SYN floods:
|
||||||
|
```ini
|
||||||
|
net.core.somaxconn = 65535
|
||||||
|
net.core.netdev_max_backlog = 65535
|
||||||
|
net.ipv4.tcp_max_syn_backlog = 65535
|
||||||
|
net.ipv4.tcp_syncookies = 1
|
||||||
|
```
|
||||||
|
### 2.2 Port Exhaustion & TIME-WAIT Sockets
|
||||||
|
High churn rates lead to ephemeral port exhaustion. Expand the range and rapidly recycle closed sockets:
|
||||||
|
```ini
|
||||||
|
net.ipv4.ip_local_port_range = 10000 65535
|
||||||
|
net.ipv4.tcp_fin_timeout = 15
|
||||||
|
net.ipv4.tcp_tw_reuse = 1
|
||||||
|
net.ipv4.tcp_max_tw_buckets = 2000000
|
||||||
|
```
|
||||||
|
### 2.3 TCP Keepalive (Aggressive Dead Connection Culling)
|
||||||
|
By default, Linux keeps silent, dropped connections open for over 2 hours. This consumes memory at scale. Configure the system to detect and drop them in < 5 minutes:
|
||||||
|
```ini
|
||||||
|
net.ipv4.tcp_keepalive_time = 300
|
||||||
|
net.ipv4.tcp_keepalive_intvl = 30
|
||||||
|
net.ipv4.tcp_keepalive_probes = 5
|
||||||
|
```
|
||||||
|
### 2.4 TCP Buffers & Congestion Control
|
||||||
|
Optimize memory usage per socket and switch to BBR (Bottleneck Bandwidth and Round-trip propagation time) to improve latency on lossy networks:
|
||||||
|
```ini
|
||||||
|
# Core buffer sizes
|
||||||
|
net.core.rmem_default = 262144
|
||||||
|
net.core.wmem_default = 262144
|
||||||
|
net.core.rmem_max = 16777216
|
||||||
|
net.core.wmem_max = 16777216
|
||||||
|
# TCP specific buffers (min, default, max)
|
||||||
|
net.ipv4.tcp_rmem = 4096 87380 16777216
|
||||||
|
net.ipv4.tcp_wmem = 4096 65536 16777216
|
||||||
|
# Enable BBR
|
||||||
|
net.core.default_qdisc = fq
|
||||||
|
net.ipv4.tcp_congestion_control = bbr
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## 3. Conntrack (Netfilter) Tuning
|
||||||
|
If your server uses `iptables`, `ufw`, or `firewalld`, the Linux kernel tracks every connection state in a table (`nf_conntrack`). When this table fills up, Linux drops new packets.
|
||||||
|
Check your current limit and usage:
|
||||||
|
```bash
|
||||||
|
sysctl net.netfilter.nf_conntrack_max
|
||||||
|
sysctl net.netfilter.nf_conntrack_count
|
||||||
|
```
|
||||||
|
If it gets close to the limit, tune it up, and reduce the time established connections linger in the tracker:
|
||||||
|
```ini
|
||||||
|
# In /etc/sysctl.d/99-telemt-highload.conf
|
||||||
|
net.netfilter.nf_conntrack_max = 2097152
|
||||||
|
# Reduce timeout from default 5 days to 1 hour
|
||||||
|
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
|
||||||
|
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 12
|
||||||
|
```
|
||||||
|
*Note: Depending on your OS, you may need to run `modprobe nf_conntrack` before setting these parameters.*
|
||||||
|
|
||||||
|
---
|
||||||
|
## 4. Multi-Tier Architecture: HAProxy Setup
|
||||||
|
For massive traffic loads, buffering Telemt behind a reverse proxy like HAProxy can help absorb connection spikes and handle basic TCP connections before handing them off.
|
||||||
|
### HAProxy High-Load `haproxy.cfg`
|
||||||
|
```haproxy
|
||||||
|
global
|
||||||
|
# Disable detailed logging under load
|
||||||
|
log stdout format raw local0 err
|
||||||
|
# maxconn 250000
|
||||||
|
|
||||||
|
# Buffer tuning
|
||||||
|
tune.bufsize 16384
|
||||||
|
tune.maxaccept 64
|
||||||
|
defaults
|
||||||
|
log global
|
||||||
|
mode tcp
|
||||||
|
option clitcpka
|
||||||
|
option srvtcpka
|
||||||
|
timeout connect 5s
|
||||||
|
timeout client 1h
|
||||||
|
timeout server 1h
|
||||||
|
# Quick purge for dead peers
|
||||||
|
timeout client-fin 10s
|
||||||
|
timeout server-fin 10s
|
||||||
|
frontend proxy_in
|
||||||
|
bind *:443
|
||||||
|
maxconn 250000
|
||||||
|
option tcp-smart-accept
|
||||||
|
default_backend telemt_backend
|
||||||
|
backend telemt_backend
|
||||||
|
option tcp-smart-connect
|
||||||
|
# Send-Proxy-V2 to preserve Client IP for Telemt's internal logic
|
||||||
|
server telemt_core 10.10.10.1:443 maxconn 250000 send-proxy-v2 check inter 5s
|
||||||
|
```
|
||||||
|
**Important**: Telemt must be configured to process the `PROXY` protocol on port `443` for this chain to work and preserve client IPs.
|
||||||
|
|
||||||
|
---
|
||||||
|
## 5. Diagnostics & Monitoring
|
||||||
|
When operating under load, these commands are useful for diagnostics:
|
||||||
|
* **Checking dropped connections (Queues full)**: `netstat -s | grep "times the listen queue of a socket overflowed"`
|
||||||
|
* **Checking Conntrack drops**: `dmesg | grep conntrack`
|
||||||
|
* **Checking File Descriptor usage**: `cat /proc/sys/fs/file-nr`
|
||||||
|
* **Real-time connection states**: `ss -s` (Avoid using `netstat` on heavy loads).
|
||||||
139
docs/Advanced_settings/HIGH_LOAD.ru.md
Normal file
139
docs/Advanced_settings/HIGH_LOAD.ru.md
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
# Руководство по High-Load конфигурации и тюнингу
|
||||||
|
При развертывании Telemt под высокой нагрузкой (десятки и сотни тысяч одновременных подключений), стандартные ограничения сетевого стека ОС могут приводить к потерям пакетов, переключениям контекста CPU и отказам в соединениях. В данном руководстве описана настройка ядра Linux, системных лимитов и аппаратной конфигурации для работы в подобных сценариях.
|
||||||
|
|
||||||
|
---
|
||||||
|
## 1. Системные лимиты и файловые дескрипторы
|
||||||
|
Каждое TCP-сосоединение требует файлового дескриптора. При 100 тысячах соединений стандартные лимиты Linux (зачастую 1024 или 65535) будут исчерпаны немедленно.
|
||||||
|
### Общесистемные лимиты (`sysctl`)
|
||||||
|
Увеличьте глобальный лимит файловых дескрипторов в `/etc/sysctl.conf`:
|
||||||
|
```ini
|
||||||
|
fs.file-max = 2097152
|
||||||
|
fs.nr_open = 2097152
|
||||||
|
```
|
||||||
|
### На уровне пользователя (`limits.conf`)
|
||||||
|
Отредактируйте `/etc/security/limits.conf`, чтобы разрешить пользователю (от которого запущен telemt) резервировать дескрипторы:
|
||||||
|
```conf
|
||||||
|
* soft nofile 1048576
|
||||||
|
* hard nofile 1048576
|
||||||
|
root soft nofile 1048576
|
||||||
|
root hard nofile 1048576
|
||||||
|
```
|
||||||
|
### Переопределения для Systemd / Docker
|
||||||
|
Если используется **Systemd**, добавьте в ваш `telemt.service`:
|
||||||
|
```ini
|
||||||
|
[Service]
|
||||||
|
LimitNOFILE=1048576
|
||||||
|
LimitNPROC=65535
|
||||||
|
TasksMax=infinity
|
||||||
|
```
|
||||||
|
Если используется **Docker**, задайте `ulimits` в `docker-compose.yaml`:
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
telemt:
|
||||||
|
ulimits:
|
||||||
|
nofile:
|
||||||
|
soft: 1048576
|
||||||
|
hard: 1048576
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## 2. Тонкая настройка сетевого стека ядра (`sysctl`)
|
||||||
|
Создайте выделенный файл `/etc/sysctl.d/99-telemt-highload.conf` и примените его через `sysctl -p /etc/sysctl.d/99-telemt-highload.conf`.
|
||||||
|
### 2.1 Очереди соединений и защита от SYN-флуда
|
||||||
|
Увеличьте размеры очередей, чтобы поглощать внезапные всплески соединений и смягчить атаки типа SYN flood:
|
||||||
|
```ini
|
||||||
|
net.core.somaxconn = 65535
|
||||||
|
net.core.netdev_max_backlog = 65535
|
||||||
|
net.ipv4.tcp_max_syn_backlog = 65535
|
||||||
|
net.ipv4.tcp_syncookies = 1
|
||||||
|
```
|
||||||
|
### 2.2 Исчерпание портов и TIME-WAIT сокеты
|
||||||
|
Высокая текучесть приводит к нехватке временных (ephemeral) портов. Расширьте диапазон портов и позвольте ядру быстро переиспользовать закрытые сокеты:
|
||||||
|
```ini
|
||||||
|
net.ipv4.ip_local_port_range = 10000 65535
|
||||||
|
net.ipv4.tcp_fin_timeout = 15
|
||||||
|
net.ipv4.tcp_tw_reuse = 1
|
||||||
|
net.ipv4.tcp_max_tw_buckets = 2000000
|
||||||
|
```
|
||||||
|
### 2.3 TCP Keepalive (Агрессивная очистка мертвых соединений)
|
||||||
|
По умолчанию Linux держит "оборванные" TCP-сессии более 2 часов. Задайте параметры для обнаружения и сброса мертвых соединений за менее чем 5 минут:
|
||||||
|
```ini
|
||||||
|
net.ipv4.tcp_keepalive_time = 300
|
||||||
|
net.ipv4.tcp_keepalive_intvl = 30
|
||||||
|
net.ipv4.tcp_keepalive_probes = 5
|
||||||
|
```
|
||||||
|
### 2.4 Буферы TCP и управление перегрузками (Congestion Control)
|
||||||
|
Оптимизируйте использование памяти на сокет и переключитесь на алгоритм BBR (Bottleneck Bandwidth and Round-trip propagation time) для улучшения задержки на плохих сетях:
|
||||||
|
```ini
|
||||||
|
# Размеры буферов ядра (по умолчанию и макс)
|
||||||
|
net.core.rmem_default = 262144
|
||||||
|
net.core.wmem_default = 262144
|
||||||
|
net.core.rmem_max = 16777216
|
||||||
|
net.core.wmem_max = 16777216
|
||||||
|
# Специфичные TCP буферы (min, default, max)
|
||||||
|
net.ipv4.tcp_rmem = 4096 87380 16777216
|
||||||
|
net.ipv4.tcp_wmem = 4096 65536 16777216
|
||||||
|
# Включение BBR
|
||||||
|
net.core.default_qdisc = fq
|
||||||
|
net.ipv4.tcp_congestion_control = bbr
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## 3. Тюнинг Conntrack (Netfilter)
|
||||||
|
Если ваш сервер использует `iptables`, `ufw` или `firewalld`, ядро вынуждено отслеживать каждое соединение в таблице состояний (`nf_conntrack`). Когда эта таблица переполняется, Linux отбрасывает новые пакеты без уведомления приложения.
|
||||||
|
Проверьте текущие лимиты и использование:
|
||||||
|
```bash
|
||||||
|
sysctl net.netfilter.nf_conntrack_max
|
||||||
|
sysctl net.netfilter.nf_conntrack_count
|
||||||
|
```
|
||||||
|
Если вы близки к пределу, увеличьте таблицу и заставьте ядро быстрее удалять установленные соединения. Добавьте в `/etc/sysctl.d/99-telemt-highload.conf`:
|
||||||
|
```ini
|
||||||
|
net.netfilter.nf_conntrack_max = 2097152
|
||||||
|
# Снижаем таймаут с дефолтных 5 дней до 1 часа
|
||||||
|
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
|
||||||
|
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 12
|
||||||
|
```
|
||||||
|
*Внимание: в зависимости от ОС, вам может потребоваться выполнить `modprobe nf_conntrack` перед установкой этих параметров.*
|
||||||
|
|
||||||
|
---
|
||||||
|
## 4. Архитектура: Развертывание за HAProxy
|
||||||
|
Для максимальных нагрузок выставление Telemt напрямую в интернет менее эффективно, чем использование оптимизированного L4-балансировщика. HAProxy эффективен в поглощении TCP атак, обработке рукопожатий и сглаживании всплесков подключений.
|
||||||
|
### Оптимизация `haproxy.cfg` для High-Load
|
||||||
|
```haproxy
|
||||||
|
global
|
||||||
|
# Отключить детальные логи соединений под нагрузкой
|
||||||
|
log stdout format raw local0 err
|
||||||
|
maxconn 250000
|
||||||
|
# Тюнинг буферов и приема сокетов
|
||||||
|
tune.bufsize 16384
|
||||||
|
tune.maxaccept 64
|
||||||
|
defaults
|
||||||
|
log global
|
||||||
|
mode tcp
|
||||||
|
option clitcpka
|
||||||
|
option srvtcpka
|
||||||
|
timeout connect 5s
|
||||||
|
timeout client 1h
|
||||||
|
timeout server 1h
|
||||||
|
# Быстрая очистка мертвых пиров
|
||||||
|
timeout client-fin 10s
|
||||||
|
timeout server-fin 10s
|
||||||
|
frontend proxy_in
|
||||||
|
bind *:443
|
||||||
|
maxconn 250000
|
||||||
|
option tcp-smart-accept
|
||||||
|
default_backend telemt_backend
|
||||||
|
backend telemt_backend
|
||||||
|
option tcp-smart-connect
|
||||||
|
# Send-Proxy-V2 обязателен для сохранения IP клиента внутри внутренней логики Telemt
|
||||||
|
server telemt_core 10.10.10.1:443 maxconn 250000 send-proxy-v2 check inter 5s
|
||||||
|
```
|
||||||
|
**Важно**: Telemt должен быть настроен на обработку протокола `PROXY` на порту `443`, чтобы получать оригинальные IP-адреса клиентов.
|
||||||
|
|
||||||
|
---
|
||||||
|
## 5. Диагностика
|
||||||
|
Команды для выявления узких мест:
|
||||||
|
* **Проверка дропов TCP (переполнение очередей)**: `netstat -s | grep "times the listen queue of a socket overflowed"`
|
||||||
|
* **Контроль отбрасывания пакетов Conntrack**: `dmesg | grep conntrack`
|
||||||
|
* **Проверка использования файловых дескрипторов**: `cat /proc/sys/fs/file-nr`
|
||||||
|
* **Отображение состояния сокетов**: `ss -s` (Избегайте использования `netstat` под высокой нагрузкой).
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
12
docs/assets/telegram_button.svg
Executable file → Normal file
12
docs/assets/telegram_button.svg
Executable file → Normal file
@@ -1,11 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="250" height="50" viewBox="0 0 250 50">
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 150 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><path d="M150,15c0,8.279 -6.721,15 -15,15l-120,0c-8.279,0 -15,-6.721 -15,-15c0,-8.279 6.721,-15 15,-15l120,0c8.279,0 15,6.721 15,15Z" style="fill:#24a1ed;"/><g transform="matrix(20.833333,0,0,20.833333,111.464184,22.329305)"></g><text x="39.666px" y="22.329px" style="font-family:'ArialMT', 'Arial', sans-serif;font-size:20.833px;fill:#fff;">Join us!</text></svg>
|
||||||
<defs>
|
|
||||||
<style>
|
|
||||||
.cls-1 {
|
|
||||||
fill: #1d98dc;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</defs>
|
|
||||||
<rect id="Прямоугольник_скругл._углы_1" data-name="Прямоугольник, скругл. углы 1" class="cls-1" width="250" height="50" rx="25" ry="25"/>
|
|
||||||
<image id="Join_us_" data-name="Join us!" x="53" y="12" width="144" height="24" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAAAYCAYAAAAVpXQNAAAFnElEQVRoge2aS2hdRRjHf2Pro1aRW1BBpGpLUQRbNRbxsbCSSKWCD7gVFUFEko1gdykaxQeU1NdGEBpEXLjQdOPCLqSh4koXLUhXUk1a8YFQSVqlYm3tJ1/5bpl8mTn33Nxzb25q/nDbnDMzZ+Z88/+ec4KI0EFcDdwM/A183cmJlrBAUAJ16LdOREZEZJ+IfFTRHLtkNtZ0UmoiMm6zTYpI3/+ZoyprJ3vdC5ZXOEcALgT6gacAFfgNwEXAsQrn6QpEZBio21xK1F3AHYvtPapCCGHKeasZ/acKAl0KXAM8CjwNrAMucX3+6fYLL6HjaItAy4DVwHrgceARYIW16YNPAZfbtdJ2arHtZwhhp7mtuq1/qAeW1XNolUCrzDXdbRZng2vfB3wFPAncaPdOAN8vRuGEELb2wDJ6GmUItMJigAeAe4H7jEgxfgXeM/I8B6yN2v5YrARaQnMUEUgD4NuALcDtwK2Zfp8BO4DfgXfNncX4DfhhaS/OC0yZMTmHC9xbqbXZBIwAHwNjwLMZ8hwCtgFPACeB3QnyKL6zX9chIoMiMipzoWn5cFEZIJG2Dif6zCorRPfrIrLXjR9tp+zgU+iCfoOu72CmX5/JYNr1n7b75coWVl9ZLSLPi8gnIvKziJxOCD3GByKy0cZuFpEjmX6nROQVEbmim3UgE87+Ju/QwBxi0AaBEmuMMT1fErnntEWgjFJ5pMZNxvJo1IE+BO4Crk+k3x4HgLeAzy04fsbcVi3TXyvQh4G/WpTXvGGas7+F8SrMs1lXBXOPAkmNN9SsnjTQ7lzzha0xqTQt4mwary5sI3BTE/IoAd4GHgM+tesXgPcLyKM4CkwC/3ZJOLqWcXdbXetAMFgC4MmiJOqvYAm6MRNacIzm2+769C9UVdvkExNcY5qtIYIVS3PKNONvLLfM6jrgYWCz/X2lVZC1nvMN8CrwpdV0VpqgXkrEUB4/WgZ2pjIpFGPQBXljIYRZ9ZsQggphu4jo/6NR06Btfjs4EEIYcPPtNLcVb1y/WfNuo+YUXuWz2633QMHa5hBICXAcOAi8AdwDPAS8Duyxe1usvqPkucqE/nIJ8ih+MivULdSjeWYS2h8LaqcTVBUWKKe5Y+66yGp3Ep4Ag+2eJ6bS+G/t56Ex0ptuk4pw2txXV2DmOXYNE2ZtijARjampazENnC9yFsxX4heEQCoPERmLrKGSZ9LuTXhrVAZlrAgWH420QB7Fn2bZugW/KWWIUOnG5ghbgsjdxPYE0ZVQ440UvpW1lCWQuq5bWnzJoxlL1g4WyvSfN1AyW5w2lFGgUSuBpFxbrAhnx7ZigVqFEuhIxYKf9VL6iUF06bW8DNm8kBbLoW/bihRC0AB6rWVdPlbss3KDx1b7bCc0rFhZAq10p+uvAe/Y3zkcatLeKnyMM8tFmZuISVRUj2kgDpxnHCF7DfG7FQW+LQXFGvNZQrHKJxUWVxZiPgTaZtnZiBUSU1bmZAfSVO+bUwFfnO3UrGiWhPn6vszYXkRM7r5U3SpRLpjTnotxTAG9TJvXq0oeITwoIr+IyDYRWebaNojIFyJyJipzHxeRO9s4shi244jGtS+9T6e0wwTkz3bGY2HruMzz1iSeFaP0WVhGzqWOIgrG+zVr9lSP2uvuqGHOUUb0TnvjsdbWnzj+qWXWMG3zlSbQehHZJCIXZ9p1U3aIyDGbQD9/vKzCM6+sUBKCrjcZm0JSm12/hSaQX08O4+5+ikBlMOrm93JVEpV2YQetEn0y067m70Uzn3vsfOxEq0IqiSENAHNdrZYxkKqaJjBlxxztVqA7DovPmn0VmUrR54PdIYRsETZCrYoT8vi3UkTuF5Fr23zOcEJDCj+/SMHGeI0Uu1dY7+g1CxQ9R12Nt9DnXFKz03gbn5Jv4zOObEXeudG6iPAfDgYBtHqBCrAAAAAASUVORK5CYII="/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 804 B |
1222
tools/grafana-dashboard-by-user.json
Normal file
1222
tools/grafana-dashboard-by-user.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user