diff options
| author | murilo ijanc | 2026-03-25 22:19:32 -0300 |
|---|---|---|
| committer | murilo ijanc | 2026-03-25 22:19:32 -0300 |
| commit | 1cc0f3b34c7ff29675d5130a1c17fe5ab7f16ac6 (patch) | |
| tree | 21178394cbbce34ac0902b6eaa798a8598c535c6 /src | |
| parent | 97cc9c29c3017c7d72d304e4206aefcdf4839c85 (diff) | |
| download | tesseras-dht-1cc0f3b34c7ff29675d5130a1c17fe5ab7f16ac6.tar.gz | |
Add unban() to BanList and expose it on Node
Allows callers to clear bans for specific addresses, needed
for re-join logic where bootstrap peers may have been banned
after transient failures.
Diffstat (limited to 'src')
| -rw-r--r-- | src/banlist.rs | 6 | ||||
| -rw-r--r-- | src/node.rs | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/banlist.rs b/src/banlist.rs index f01e31a..4827242 100644 --- a/src/banlist.rs +++ b/src/banlist.rs @@ -102,6 +102,12 @@ impl BanList { .retain(|_, e| e.last_failure.elapsed() < self.ban_duration); } + /// Remove a specific ban and its failure history. + pub fn unban(&mut self, addr: &SocketAddr) { + self.bans.remove(addr); + self.failures.remove(addr); + } + /// Number of currently active bans. pub fn ban_count(&self) -> usize { self.bans diff --git a/src/node.rs b/src/node.rs index fef917e..2c3cec9 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1165,6 +1165,11 @@ impl Node { self.peers.len() } + /// Remove a ban for a specific address. + pub fn unban(&mut self, addr: &std::net::SocketAddr) { + self.ban_list.unban(addr); + } + /// Snapshot of metrics counters. pub fn metrics(&self) -> crate::metrics::MetricsSnapshot { self.metrics.snapshot() |