From a947f3a8cbad03b939dedfc1486de75226d90c0a Mon Sep 17 00:00:00 2001 From: Sofia Date: Fri, 17 Jul 2026 22:12:17 +0300 Subject: [PATCH] Add toggle to disable accepting new connections --- src/connections.rs | 20 ++++++++++++++++---- src/lib.rs | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/connections.rs b/src/connections.rs index 054ca51..1498206 100644 --- a/src/connections.rs +++ b/src/connections.rs @@ -49,6 +49,8 @@ pub(crate) struct ConnectionManager< connections: HashMap>, closing_since: Option, config: PeerConfig, + + accepting_connections: bool, } impl @@ -61,6 +63,7 @@ impl { @@ -413,6 +421,10 @@ impl Vec> { self.connections.values().cloned().collect() } + + pub fn set_accepting_connections(&mut self, accepting: bool) { + self.accepting_connections = accepting; + } } /// Wrap UdpSocket with some helper methods diff --git a/src/lib.rs b/src/lib.rs index dd842e3..f885f79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -238,6 +238,10 @@ impl NetStats { let conns = self.connection_mgr.connections(); let all_stats = conns.iter().map(|c| c.statistics());