From b2c7d6bdaba9ba6296c567bb2595325dde86d13d Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Tue, 8 Feb 2022 09:28:53 -0800 Subject: [PATCH] ban time --- src/pool.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pool.rs b/src/pool.rs index 073c20a..874fd61 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -38,6 +38,7 @@ pub struct ConnectionPool { round_robin: Counter, banlist: BanList, healthcheck_timeout: u64, + ban_time: i64, } impl ConnectionPool { @@ -74,6 +75,7 @@ impl ConnectionPool { round_robin: Arc::new(AtomicUsize::new(0)), banlist: Arc::new(Mutex::new(vec![HashMap::new()])), healthcheck_timeout: HEALTHCHECK_TIMEOUT, + ban_time: BAN_TIME, } } @@ -133,6 +135,7 @@ impl ConnectionPool { round_robin: Arc::new(AtomicUsize::new(0)), banlist: Arc::new(Mutex::new(banlist)), healthcheck_timeout: config.general.healthcheck_timeout, + ban_time: config.general.ban_time, } } @@ -229,7 +232,7 @@ impl ConnectionPool { match guard[shard].get(address) { Some(timestamp) => { let now = chrono::offset::Utc::now().naive_utc(); - if now.timestamp() - timestamp.timestamp() > BAN_TIME { + if now.timestamp() - timestamp.timestamp() > self.ban_time { // 1 minute guard[shard].remove(address); false