Refactor proxy and transport modules for improved safety and performance

- Enhanced linting rules in `src/proxy/mod.rs` to enforce stricter code quality checks in production.
- Updated hash functions in `src/proxy/middle_relay.rs` for better efficiency.
- Added new security tests in `src/proxy/tests/middle_relay_stub_completion_security_tests.rs` to validate desynchronization behavior.
- Removed ignored test stubs in `src/proxy/tests/middle_relay_security_tests.rs` to clean up the test suite.
- Improved error handling and code readability in various transport modules, including `src/transport/middle_proxy/config_updater.rs` and `src/transport/middle_proxy/pool.rs`.
- Introduced new padding functions in `src/stream/frame_stream_padding_security_tests.rs` to ensure consistent behavior across different implementations.
- Adjusted TLS stream validation in `src/stream/tls_stream.rs` for better boundary checking.
- General code cleanup and dead code elimination across multiple files to enhance maintainability.
This commit is contained in:
David Osipov
2026-03-21 20:05:07 +04:00
parent a6c298b633
commit 4c32370b25
35 changed files with 794 additions and 174 deletions
+11 -4
View File
@@ -199,8 +199,12 @@ impl ConnectionPool {
/// Close all pooled connections
pub async fn close_all(&self) {
let pools = self.pools.read();
for (addr, pool) in pools.iter() {
let pools_snapshot: Vec<(SocketAddr, Arc<Mutex<PoolInner>>)> = {
let pools = self.pools.read();
pools.iter().map(|(addr, pool)| (*addr, Arc::clone(pool))).collect()
};
for (addr, pool) in pools_snapshot {
let mut inner = pool.lock().await;
let count = inner.connections.len();
inner.connections.clear();
@@ -210,12 +214,15 @@ impl ConnectionPool {
/// Get pool statistics
pub async fn stats(&self) -> PoolStats {
let pools = self.pools.read();
let pools_snapshot: Vec<Arc<Mutex<PoolInner>>> = {
let pools = self.pools.read();
pools.values().cloned().collect()
};
let mut total_connections = 0;
let mut total_pending = 0;
let mut endpoints = 0;
for pool in pools.values() {
for pool in pools_snapshot {
let inner = pool.lock().await;
total_connections += inner.connections.len();
total_pending += inner.pending;