From a0760827631d85bea5d653b26760edc1417c45b4 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 9 Dec 2023 20:43:38 -0500 Subject: [PATCH] punish clear --- veilid-core/src/network_manager/address_filter.rs | 7 +++++++ veilid-core/src/veilid_api/debug.rs | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/veilid-core/src/network_manager/address_filter.rs b/veilid-core/src/network_manager/address_filter.rs index 15775e02..2eb104a6 100644 --- a/veilid-core/src/network_manager/address_filter.rs +++ b/veilid-core/src/network_manager/address_filter.rs @@ -268,6 +268,13 @@ impl AddressFilter { .or_insert(ts); } + pub fn clear_punishments(&self) { + let mut inner = self.inner.lock(); + inner.punishments_by_ip4.clear(); + inner.punishments_by_ip6_prefix.clear(); + inner.punishments_by_node_id.clear(); + } + pub fn punish_ip_addr(&self, addr: IpAddr) { log_net!(debug ">>> PUNISHED: {}", addr); let ts = get_aligned_timestamp(); diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 901fe9b6..f67ca339 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -1710,10 +1710,20 @@ impl VeilidAPI { let network_manager = self.network_manager()?; let address_filter = network_manager.address_filter(); - let out = format!("Address Filter Punishments:\n{:#?}", address_filter); + let out = format!("Address filter punishments:\n{:#?}", address_filter); Ok(out) } + async fn debug_punish_clear(&self, _args: Vec) -> VeilidAPIResult { + // + let network_manager = self.network_manager()?; + let address_filter = network_manager.address_filter(); + + address_filter.clear_punishments(); + + Ok("Address Filter punishments cleared\n".to_owned()) + } + async fn debug_punish(&self, args: String) -> VeilidAPIResult { let args: Vec = shell_words::split(&args).map_err(|e| VeilidAPIError::parse_error(e, args))?; @@ -1750,6 +1760,7 @@ appcall appreply [#id] relay [public|local] punish list + clear route allocate [ord|*ord] [rel] [] [in|out] release publish [full]