From b6206a6dfebe92bf6689e03983e77a42e7c2ad10 Mon Sep 17 00:00:00 2001 From: kavore <161734431+kavore@users.noreply.github.com> Date: Mon, 16 Mar 2026 20:40:10 +0300 Subject: [PATCH 1/4] feat: make max_connections configurable via [server] section The concurrent connection limit was hardcoded to 10,000. Add server.max_connections config option (default: 10000, 0 = unlimited). --- src/config/defaults.rs | 4 ++++ src/config/types.rs | 6 ++++++ src/maestro/mod.rs | 9 +++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/config/defaults.rs b/src/config/defaults.rs index 82ec0b3..ea9250d 100644 --- a/src/config/defaults.rs +++ b/src/config/defaults.rs @@ -147,6 +147,10 @@ pub(crate) fn default_proxy_protocol_header_timeout_ms() -> u64 { 500 } +pub(crate) fn default_server_max_connections() -> u32 { + 10_000 +} + pub(crate) fn default_prefer_4() -> u8 { 4 } diff --git a/src/config/types.rs b/src/config/types.rs index 04a22ce..f676f54 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -1167,6 +1167,11 @@ pub struct ServerConfig { #[serde(default)] pub listeners: Vec, + + /// Maximum number of concurrent client connections. + /// 0 means unlimited. + #[serde(default = "default_server_max_connections")] + pub max_connections: u32, } impl Default for ServerConfig { @@ -1184,6 +1189,7 @@ impl Default for ServerConfig { metrics_whitelist: default_metrics_whitelist(), api: ApiConfig::default(), listeners: Vec::new(), + max_connections: default_server_max_connections(), } } } diff --git a/src/maestro/mod.rs b/src/maestro/mod.rs index 047c204..da00b40 100644 --- a/src/maestro/mod.rs +++ b/src/maestro/mod.rs @@ -349,8 +349,13 @@ pub async fn run() -> std::result::Result<(), Box> { let beobachten = Arc::new(BeobachtenStore::new()); let rng = Arc::new(SecureRandom::new()); - // Connection concurrency limit - let max_connections = Arc::new(Semaphore::new(10_000)); + // Connection concurrency limit (0 = unlimited) + let max_connections_limit = if config.server.max_connections == 0 { + Semaphore::MAX_PERMITS + } else { + config.server.max_connections as usize + }; + let max_connections = Arc::new(Semaphore::new(max_connections_limit)); let me2dc_fallback = config.general.me2dc_fallback; let me_init_retry_attempts = config.general.me_init_retry_attempts; From 2c10560795c4c25c8f8d235a439a927488f0f57c Mon Sep 17 00:00:00 2001 From: Alexey <247128645+axkurcom@users.noreply.github.com> Date: Mon, 16 Mar 2026 21:25:14 +0300 Subject: [PATCH 2/4] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ac529af..9374924 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "telemt" -version = "3.3.18" +version = "3.3.19" edition = "2024" [dependencies] From ee4d15fed64c56b12c8b06155b0894493961e7f5 Mon Sep 17 00:00:00 2001 From: Dimasssss Date: Mon, 16 Mar 2026 22:02:55 +0300 Subject: [PATCH 3/4] Update FAQ.ru.md --- docs/FAQ.ru.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/FAQ.ru.md b/docs/FAQ.ru.md index cb5db7f..4353e98 100644 --- a/docs/FAQ.ru.md +++ b/docs/FAQ.ru.md @@ -83,6 +83,13 @@ metrics_whitelist = ["127.0.0.1/32", "::1/128", "0.0.0.0/0"] public_host = "proxy.example.com" ``` +### Общий лимит подключений к серверу +Ограничивает общее число открытых подключений к серверу: +```toml +[server] +max_connections = 10000 # 0 - unlimited, 10000 - default +``` + ### Upstream Manager Чтобы указать апстрим, добавьте в секцию `[[upstreams]]` файла config.toml: #### Привязка к IP @@ -113,3 +120,4 @@ password = "pass" # Password for Auth on SOCKS-server weight = 1 # Set Weight for Scenarios enabled = true ``` + From e1ef192c1096a34945464017dc03eef62a110ad5 Mon Sep 17 00:00:00 2001 From: Dimasssss Date: Mon, 16 Mar 2026 22:03:28 +0300 Subject: [PATCH 4/4] Update FAQ.en.md --- docs/FAQ.en.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/FAQ.en.md b/docs/FAQ.en.md index e3a6519..25522ad 100644 --- a/docs/FAQ.en.md +++ b/docs/FAQ.en.md @@ -83,6 +83,13 @@ To specify a domain in the links, add to the `[general.links]` section of the co public_host = "proxy.example.com" ``` +### Server connection limit +Limits the total number of open connections to the server: +```toml +[server] +max_connections = 10000 # 0 - unlimited, 10000 - default +``` + ### Upstream Manager To specify an upstream, add to the `[[upstreams]]` section of the config.toml file: #### Binding to IP