From fb4306e1e46e4289627a73085e2f2df64ba48bc4 Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Sun, 14 Jan 2024 15:55:06 +0100 Subject: [PATCH] store: fix logic error in greylist_store_or_update previously we were checking whether the entry is in any of the hostlists (hostlist_contains) prior to storing entries in the greylist. this creates a logic error which we have now fixed. the impact is we will now likely have duplicate connections between the greylist and other lists. however, it shouldn't be a problem. --- src/net/hosts/store.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/net/hosts/store.rs b/src/net/hosts/store.rs index 7cd3dbf1f..a1f71195a 100644 --- a/src/net/hosts/store.rs +++ b/src/net/hosts/store.rs @@ -283,7 +283,7 @@ impl Hosts { let filtered_addrs = self.filter_addresses(addrs).await; let filtered_addrs_len = filtered_addrs.len(); for (addr, last_seen) in filtered_addrs { - if !self.hostlist_contains(&addr).await { + if !self.greylist_contains(&addr).await { debug!(target: "store::greylist_store_or_update()", "We do not have this entry in the hostlist. Adding to store..."); self.greylist_store(addr.clone(), last_seen.clone()).await; @@ -915,7 +915,8 @@ impl Hosts { ret.push((addr.clone(), *last_seen)); limit -= 1; if limit == 0 { - debug!(target: "deadlock", "Found matching grey scheme, returning"); + debug!(target: "deadlock", "Found matching grey scheme, returning len: {}", ret.len()); + debug!(target: "store::greylist_fetch_with_schemes", "Found matching greylist entry, returning"); return ret } @@ -985,8 +986,8 @@ impl Hosts { trace!(target: "store::anchorlist_fetch_with_schemes", "[START]"); let mut ret = vec![]; + // Select from the anchorlist providing it's not empty. if !self.is_empty_anchorlist().await { - // Select from the anchorlist providing it's not empty. let anchorlist = self.anchorlist.read().await; let mut parsed_limit = match limit { @@ -1017,14 +1018,13 @@ impl Hosts { } } - // Anchorlist is empty! + // Select from the whitelist providing it's not empty. if !self.is_empty_whitelist().await { return self.whitelist_fetch_with_schemes(schemes, limit).await } - // Whitelist is empty! + // Select from the greyist providing it's not empty. if !self.is_empty_greylist().await { - // Select from the greyist providing it's not empty. return self.greylist_fetch_with_schemes(schemes, limit).await }