|
|
@@ -201,7 +201,7 @@ impl Hosts {
|
|
|
if registry.contains_key(&addr) {
|
|
|
let current_state = registry.get(&addr).unwrap().clone();
|
|
|
|
|
|
- debug!(target: "store::try_update_registry()",
|
|
|
+ debug!(target: "net::hosts::store::try_update_registry()",
|
|
|
"Attempting to update addr={} current_state={}, new_state={}",
|
|
|
addr, current_state, new_state.to_string());
|
|
|
|
|
|
@@ -228,14 +228,14 @@ impl Hosts {
|
|
|
pub async fn check_address(&self, hosts: Vec<(Url, u64)>) -> Option<(Url, u64)> {
|
|
|
// Try to find an unused host in the set.
|
|
|
for (host, last_seen) in hosts {
|
|
|
- debug!(target: "store::check_address()", "Starting checks");
|
|
|
+ debug!(target: "net::hosts::store::check_address()", "Starting checks");
|
|
|
|
|
|
if let Err(_) = self.try_update_registry(host.clone(), HostState::Pending).await {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
debug!(
|
|
|
- target: "store::check_address()",
|
|
|
+ target: "net::hosts::store::check_address()",
|
|
|
"Found valid host {}",
|
|
|
host
|
|
|
);
|
|
|
@@ -249,7 +249,7 @@ impl Hosts {
|
|
|
/// process fails, or when a channel stops. Prevents hosts from getting trapped in the
|
|
|
/// HostState logical machinery.
|
|
|
pub async fn remove(&self, addr: &Url) {
|
|
|
- debug!(target: "store", "remove() Removing {} from HostRegistry", addr);
|
|
|
+ debug!(target: "net::hosts::store::remove()", "Removing {} from HostRegistry", addr);
|
|
|
self.registry.write().await.remove(addr);
|
|
|
}
|
|
|
|
|
|
@@ -293,7 +293,7 @@ impl Hosts {
|
|
|
/// (exists) or connecting (pending).
|
|
|
/// Lastly adds matching address to the pending list.
|
|
|
pub async fn greylist_fetch_address(&self, transports: &[String]) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store", "greylist_fetch_address() [START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_address()", "[START]");
|
|
|
// Collect hosts
|
|
|
let mut hosts = vec![];
|
|
|
|
|
|
@@ -332,7 +332,7 @@ impl Hosts {
|
|
|
/// (exists) or connecting (pending).
|
|
|
/// Lastly adds matching address to the pending list.
|
|
|
pub async fn whitelist_fetch_address(&self, transports: &[String]) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store", "whitelist_fetch_address() [START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_address()", "[START]");
|
|
|
// Collect hosts
|
|
|
let mut hosts = vec![];
|
|
|
|
|
|
@@ -362,7 +362,7 @@ impl Hosts {
|
|
|
hosts.push((addr, last_seen));
|
|
|
}
|
|
|
|
|
|
- trace!(target: "store::whitelist_fetch_address()",
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_address()",
|
|
|
"Grabbed hosts, length: {}", hosts.len());
|
|
|
|
|
|
hosts
|
|
|
@@ -374,7 +374,7 @@ impl Hosts {
|
|
|
/// (exists) or connecting (pending).
|
|
|
/// Lastly adds matching address to the pending list.
|
|
|
pub async fn anchorlist_fetch_address(&self, transports: &[String]) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store", "anchorlist_fetch_address() [START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_fetch_address()", "[START]");
|
|
|
// Collect hosts
|
|
|
let mut hosts = vec![];
|
|
|
|
|
|
@@ -404,7 +404,7 @@ impl Hosts {
|
|
|
hosts.push((addr, last_seen));
|
|
|
}
|
|
|
|
|
|
- trace!(target: "store::anchorlist_fetch_address()",
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_fetch_address()",
|
|
|
"Grabbed hosts, length: {}", hosts.len());
|
|
|
|
|
|
hosts
|
|
|
@@ -424,14 +424,14 @@ impl Hosts {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- debug!(target: "store::downgrade_host", "Downgrading host {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::downgrade_host()", "Downgrading host {}", addr);
|
|
|
if self.greylist_contains(addr).await {
|
|
|
- warn!(target: "store::downgrade_host",
|
|
|
+ warn!(target: "net::hosts::store::downgrade_host()",
|
|
|
"Cannot downgrade a host that is already on the greylist! {}", addr);
|
|
|
}
|
|
|
|
|
|
if self.anchorlist_contains(addr).await {
|
|
|
- debug!(target: "store::downgrade_host", "Removing from anchorlist {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::downgrade_host()", "Removing from anchorlist {}", addr);
|
|
|
|
|
|
let index = self
|
|
|
.get_anchorlist_index_at_addr(addr.clone())
|
|
|
@@ -443,7 +443,7 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if self.whitelist_contains(addr).await {
|
|
|
- debug!(target: "store::downgrade_host", "Removing from whitelist {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::downgrade_host()", "Removing from whitelist {}", addr);
|
|
|
|
|
|
let index = self
|
|
|
.get_whitelist_index_at_addr(addr.clone())
|
|
|
@@ -462,30 +462,31 @@ impl Hosts {
|
|
|
/// Stores an address on the greylist or updates its last_seen field if we already
|
|
|
/// have the address.
|
|
|
pub async fn greylist_store_or_update(&self, addrs: &[(Url, u64)]) {
|
|
|
- trace!(target: "store::greylist_store_or_update()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_store_or_update()", "[START]");
|
|
|
// Filter addresses before writing to the greylist.
|
|
|
let filtered_addrs = self.filter_addresses(addrs).await;
|
|
|
let filtered_addrs_len = filtered_addrs.len();
|
|
|
|
|
|
if filtered_addrs.is_empty() {
|
|
|
- debug!(target: "store::greylist_store_or_update()", "Filtered out all addresses");
|
|
|
+ debug!(target: "net::hosts::store::greylist_store_or_update()",
|
|
|
+ "Filtered out all addresses");
|
|
|
}
|
|
|
|
|
|
for (addr, last_seen) in filtered_addrs {
|
|
|
if !self.greylist_contains(&addr).await {
|
|
|
- debug!(target: "store::greylist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::greylist_store_or_update()",
|
|
|
"We do not have this entry in the hostlist. Adding to store...");
|
|
|
|
|
|
self.greylist_store(addr.clone(), last_seen).await;
|
|
|
} else {
|
|
|
- debug!(target: "store::greylist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::greylist_store_or_update()",
|
|
|
"We have this entry in the greylist. Updating last seen...");
|
|
|
|
|
|
let index = self
|
|
|
.get_greylist_index_at_addr(addr.clone())
|
|
|
.await
|
|
|
.expect("Expected greylist entry to exist");
|
|
|
- debug!(target: "store::greylist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::greylist_store_or_update()",
|
|
|
"Selected index, updating last seen...");
|
|
|
self.greylist_update_last_seen(&addr, last_seen, index).await;
|
|
|
self.store_subscriber.notify(filtered_addrs_len).await;
|
|
|
@@ -496,17 +497,17 @@ impl Hosts {
|
|
|
/// Stores an address on the whitelist or updates its last_seen field if we already
|
|
|
/// have the address.
|
|
|
pub async fn whitelist_store_or_update(&self, addrs: &[(Url, u64)]) {
|
|
|
- trace!(target: "store::whitelist_store_or_update()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_store_or_update()", "[START]");
|
|
|
|
|
|
// No address filtering for whitelist (whitelist is created from greylist)
|
|
|
for (addr, last_seen) in addrs {
|
|
|
if !self.whitelist_contains(addr).await {
|
|
|
- debug!(target: "store::whitelist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::whitelist_store_or_update()",
|
|
|
"We do not have this entry in the whitelist. Adding to store...");
|
|
|
|
|
|
self.whitelist_store(addr.clone(), *last_seen).await;
|
|
|
} else {
|
|
|
- debug!(target: "store::whitelist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::whitelist_store_or_update()",
|
|
|
"We have this entry in the whitelist. Updating last seen...");
|
|
|
|
|
|
let index = self
|
|
|
@@ -521,17 +522,17 @@ impl Hosts {
|
|
|
/// Stores an address on the anchorlist or updates its last_seen field if we already
|
|
|
/// have the address.
|
|
|
pub async fn anchorlist_store_or_update(&self, addrs: &[(Url, u64)]) {
|
|
|
- trace!(target: "store::anchor_store_or_update()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_store_or_update()", "[START]");
|
|
|
|
|
|
// No address filtering for anchorlist (contains addresses we have already connected to)
|
|
|
for (addr, last_seen) in addrs {
|
|
|
if !self.anchorlist_contains(addr).await {
|
|
|
- debug!(target: "store::anchorlist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::anchorlist_store_or_update()",
|
|
|
"We do not have this entry in the whitelist. Adding to store...");
|
|
|
|
|
|
self.anchorlist_store(addr.clone(), *last_seen).await;
|
|
|
} else {
|
|
|
- debug!(target: "store::anchorlist_store_or_update()",
|
|
|
+ debug!(target: "net::hosts::store::anchorlist_store_or_update()",
|
|
|
"We have this entry in the anchorlist. Updating last seen...");
|
|
|
|
|
|
let index = self
|
|
|
@@ -545,67 +546,70 @@ impl Hosts {
|
|
|
|
|
|
/// Append host to the greylist. Called on learning of a new peer.
|
|
|
pub async fn greylist_store(&self, addr: Url, last_seen: u64) {
|
|
|
- trace!(target: "store::greylist_store()", "hosts::greylist_store() [START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_store()", "[START]");
|
|
|
|
|
|
let mut greylist = self.greylist.write().await;
|
|
|
|
|
|
// Remove oldest element if the greylist reaches max size.
|
|
|
if greylist.len() == GREYLIST_MAX_LEN {
|
|
|
let last_entry = greylist.pop().unwrap();
|
|
|
- debug!(target: "store::greylist_store()", "Greylist reached max size. Removed {:?}", last_entry);
|
|
|
+ debug!(target: "net::hosts::store::greylist_store()",
|
|
|
+ "Greylist reached max size. Removed {:?}", last_entry);
|
|
|
}
|
|
|
|
|
|
- debug!(target: "store::greylist_store()", "Inserting {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::greylist_store()", "Inserting {}", addr);
|
|
|
greylist.push((addr, last_seen));
|
|
|
|
|
|
// Sort the list by last_seen.
|
|
|
greylist.sort_by_key(|entry| entry.1);
|
|
|
greylist.reverse();
|
|
|
|
|
|
- trace!(target: "store::greylist_store()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_store()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Append host to the whitelist. Called after a successful interaction with an online peer.
|
|
|
pub async fn whitelist_store(&self, addr: Url, last_seen: u64) {
|
|
|
- trace!(target: "store::whitelist_store()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_store()", "[START]");
|
|
|
|
|
|
let mut whitelist = self.whitelist.write().await;
|
|
|
|
|
|
// Remove oldest element if the whitelist reaches max size.
|
|
|
if whitelist.len() == WHITELIST_MAX_LEN {
|
|
|
let last_entry = whitelist.pop().unwrap();
|
|
|
- debug!(target: "store::whitelist_store()", "Whitelist reached max size. Removed {:?}", last_entry);
|
|
|
+ debug!(target: "net::hosts::store::whitelist_store()",
|
|
|
+ "Whitelist reached max size. Removed {:?}", last_entry);
|
|
|
}
|
|
|
- trace!(target: "store::whitelist_store()", "Inserting {}. Last seen {:?}", addr, last_seen);
|
|
|
+ trace!(target: "net::hosts::store::whitelist_store()",
|
|
|
+ "Inserting {}. Last seen {:?}", addr, last_seen);
|
|
|
whitelist.push((addr, last_seen));
|
|
|
|
|
|
// Sort the list by last_seen.
|
|
|
whitelist.sort_by_key(|entry| entry.1);
|
|
|
whitelist.reverse();
|
|
|
|
|
|
- trace!(target: "store::whitelist_store()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_store()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Append host to the anchorlist. Called after we have successfully established a connection
|
|
|
/// to a peer.
|
|
|
pub async fn anchorlist_store(&self, addr: Url, last_seen: u64) {
|
|
|
- trace!(target: "store::anchorlist_store()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_store()", "[START]");
|
|
|
|
|
|
let mut anchorlist = self.anchorlist.write().await;
|
|
|
|
|
|
- trace!(target: "store::anchorlist_store()", "Inserting {}", addr);
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_store()", "Inserting {}", addr);
|
|
|
anchorlist.push((addr, last_seen));
|
|
|
|
|
|
// Sort the list by last_seen.
|
|
|
anchorlist.sort_by_key(|entry| entry.1);
|
|
|
anchorlist.reverse();
|
|
|
|
|
|
- trace!(target: "store::anchorlist_store()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_store()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Update the last_seen field of a peer on the greylist.
|
|
|
pub async fn greylist_update_last_seen(&self, addr: &Url, last_seen: u64, index: usize) {
|
|
|
- trace!(target: "store::greylist_update_last_seen()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_update_last_seen()", "[START]");
|
|
|
|
|
|
let mut greylist = self.greylist.write().await;
|
|
|
|
|
|
@@ -615,12 +619,12 @@ impl Hosts {
|
|
|
greylist.sort_by_key(|entry| entry.1);
|
|
|
greylist.reverse();
|
|
|
|
|
|
- trace!(target: "store::greylist_update_last_seen()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_update_last_seen()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Update the last_seen field of a peer on the whitelist.
|
|
|
pub async fn whitelist_update_last_seen(&self, addr: &Url, last_seen: u64, index: usize) {
|
|
|
- trace!(target: "store::whitelist_update_last_seen()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_update_last_seen()", "[START]");
|
|
|
|
|
|
let mut whitelist = self.whitelist.write().await;
|
|
|
|
|
|
@@ -630,12 +634,12 @@ impl Hosts {
|
|
|
whitelist.sort_by_key(|entry| entry.1);
|
|
|
whitelist.reverse();
|
|
|
|
|
|
- trace!(target: "store::whitelist_update_last_seen()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_update_last_seen()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Update the last_seen field of a peer on the anchorlist.
|
|
|
pub async fn anchorlist_update_last_seen(&self, addr: &Url, last_seen: u64, index: usize) {
|
|
|
- trace!(target: "store::anchorlist_update_last_seen()", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_update_last_seen()", "[START]");
|
|
|
|
|
|
let mut anchorlist = self.anchorlist.write().await;
|
|
|
|
|
|
@@ -645,24 +649,27 @@ impl Hosts {
|
|
|
anchorlist.sort_by_key(|entry| entry.1);
|
|
|
anchorlist.reverse();
|
|
|
|
|
|
- trace!(target: "store::anchorlist_update_last_seen()", "[END]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_update_last_seen()", "[END]");
|
|
|
}
|
|
|
|
|
|
/// Remove an entry from the greylist.
|
|
|
pub async fn greylist_remove(&self, addr: &Url, index: usize) {
|
|
|
- debug!(target: "store::greylist_remove", "Removing peer {} from greylist", addr);
|
|
|
+ debug!(target: "net::hosts::store::greylist_remove()",
|
|
|
+ "Removing peer {} from greylist", addr);
|
|
|
self.greylist.write().await.remove(index);
|
|
|
}
|
|
|
|
|
|
/// Remove an entry from the whitelist.
|
|
|
pub async fn whitelist_remove(&self, addr: &Url, index: usize) {
|
|
|
- debug!(target: "store::whitelist_remove", "Removing peer {} from whitelist", addr);
|
|
|
+ debug!(target: "net::hosts::store::whitelist_remove()",
|
|
|
+ "Removing peer {} from whitelist", addr);
|
|
|
self.whitelist.write().await.remove(index);
|
|
|
}
|
|
|
|
|
|
/// Remove an entry from the anchorlist.
|
|
|
pub async fn anchorlist_remove(&self, addr: &Url, index: usize) {
|
|
|
- debug!(target: "store::anchorlist_remove", "Removing peer {} from anchorlist", addr);
|
|
|
+ debug!(target: "net::hosts::store::anchorlist_remove()",
|
|
|
+ "Removing peer {} from anchorlist", addr);
|
|
|
self.anchorlist.write().await.remove(index);
|
|
|
}
|
|
|
|
|
|
@@ -709,7 +716,7 @@ impl Hosts {
|
|
|
|
|
|
/// Filter given addresses based on certain rulesets and validity.
|
|
|
async fn filter_addresses(&self, addrs: &[(Url, u64)]) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store::filter_addresses()", "Filtering addrs: {:?}", addrs);
|
|
|
+ trace!(target: "net::hosts::store::filter_addresses()", "Filtering addrs: {:?}", addrs);
|
|
|
let mut ret = vec![];
|
|
|
let localnet = self.settings.localnet;
|
|
|
|
|
|
@@ -724,7 +731,8 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if self.is_blacklist(addr_).await {
|
|
|
- warn!(target: "store::filter_addresses()", "Peer {} is blacklisted", addr_);
|
|
|
+ warn!(target: "net::hosts::store::filter_addresses()",
|
|
|
+ "Peer {} is blacklisted", addr_);
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -764,7 +772,8 @@ impl Hosts {
|
|
|
if tor_hscrypto::pk::HsId::from_str(host_str).is_err() {
|
|
|
continue
|
|
|
}
|
|
|
- trace!(target: "store::filter_addresses()", "[Tor] Valid: {}", host_str);
|
|
|
+ trace!(target: "net::hosts::store::filter_addresses()",
|
|
|
+ "[Tor] Valid: {}", host_str);
|
|
|
}
|
|
|
|
|
|
#[cfg(feature = "p2p-nym")]
|
|
|
@@ -772,7 +781,8 @@ impl Hosts {
|
|
|
|
|
|
#[cfg(feature = "p2p-tcp")]
|
|
|
"tcp" | "tcp+tls" => {
|
|
|
- trace!(target: "store::filter_addresses()", "[TCP] Valid: {}", host_str);
|
|
|
+ trace!(target: "net::hosts::store::filter_addresses()",
|
|
|
+ "[TCP] Valid: {}", host_str);
|
|
|
}
|
|
|
|
|
|
_ => continue,
|
|
|
@@ -787,15 +797,18 @@ impl Hosts {
|
|
|
/// Quarantine a peer.
|
|
|
/// If they've been quarantined for more than a configured limit, downgrade to greylist.
|
|
|
pub async fn quarantine(&self, addr: &Url, last_seen: u64) {
|
|
|
- debug!(target: "store::quarantine()", "Quarantining peer {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::quarantine()", "Quarantining peer {}", addr);
|
|
|
let timer = Instant::now();
|
|
|
let mut q = self.quarantine.write().await;
|
|
|
if let Some(retries) = q.get_mut(addr) {
|
|
|
*retries += 1;
|
|
|
- debug!(target: "store::quarantine()", "Peer {} quarantined {} times", addr, retries);
|
|
|
+ debug!(target: "net::hosts::store::quarantine()",
|
|
|
+ "Peer {} quarantined {} times", addr, retries);
|
|
|
if *retries == self.settings.hosts_quarantine_limit {
|
|
|
- debug!(target: "store::quarantine()", "Reached quarantine limited after {:?}", timer.elapsed());
|
|
|
- debug!(target: "store::quarantine()", "Removing from hostlist {}", addr);
|
|
|
+ debug!(target: "net::hosts::store::quarantine()",
|
|
|
+ "Reached quarantine limited after {:?}", timer.elapsed());
|
|
|
+ debug!(target: "net::hosts::store::quarantine()",
|
|
|
+ "Removing from hostlist {}", addr);
|
|
|
drop(q);
|
|
|
self.downgrade_host(addr, last_seen).await;
|
|
|
}
|
|
|
@@ -978,7 +991,7 @@ impl Hosts {
|
|
|
|
|
|
/// Get a random greylist peer that matches the given transport schemes.
|
|
|
pub async fn greylist_fetch_random_with_schemes(&self) -> Option<((Url, u64), usize)> {
|
|
|
- trace!(target: "store::greylist_fetch_random_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_random_with_schemes()", "[START]");
|
|
|
|
|
|
// Retrieve all peers corresponding to that transport schemes
|
|
|
let schemes = &self.settings.allowed_transports;
|
|
|
@@ -995,7 +1008,7 @@ impl Hosts {
|
|
|
|
|
|
/// Get up to n random greylist peers. Schemes are not taken into account.
|
|
|
pub async fn greylist_fetch_n_random(&self, n: u32) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store::greylist_fetch_n_random", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_n_random()", "[START]");
|
|
|
let n = n as usize;
|
|
|
if n == 0 {
|
|
|
return vec![]
|
|
|
@@ -1009,7 +1022,8 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if hosts.is_empty() {
|
|
|
- debug!(target: "store::greylist_fetch_n_random", "No greylist entries found!");
|
|
|
+ debug!(target: "net::hosts::store::greylist_fetch_n_random()",
|
|
|
+ "No greylist entries found!");
|
|
|
return hosts
|
|
|
}
|
|
|
|
|
|
@@ -1028,12 +1042,12 @@ impl Hosts {
|
|
|
if n == 0 {
|
|
|
return vec![]
|
|
|
}
|
|
|
- trace!(target: "store::greylist_fetch_n_random_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_n_random_with_schemes()", "[START]");
|
|
|
|
|
|
// Retrieve all peers corresponding to that transport schemes
|
|
|
let hosts = self.greylist_fetch_with_schemes(schemes, None).await;
|
|
|
if hosts.is_empty() {
|
|
|
- debug!(target: "store::greylist_fetch_n_random_with_schemes",
|
|
|
+ debug!(target: "net::hosts::store::greylist_fetch_n_random_with_schemes()",
|
|
|
"No such schemes found on greylist!");
|
|
|
return hosts
|
|
|
}
|
|
|
@@ -1053,13 +1067,13 @@ impl Hosts {
|
|
|
if n == 0 {
|
|
|
return vec![]
|
|
|
}
|
|
|
- trace!(target: "store::whitelist_fetch_n_random_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_n_random_with_schemes()", "[START]");
|
|
|
|
|
|
// Retrieve all peers corresponding to that transport schemes
|
|
|
let hosts = self.whitelist_fetch_with_schemes(schemes, None).await;
|
|
|
if hosts.is_empty() {
|
|
|
- debug!(target: "store::whitelist_fetch_n_random_with_schemes",
|
|
|
- "No such schemes found on whitelist!");
|
|
|
+ debug!(target: "net::hosts::store::whitelist_fetch_n_random_with_schemes()",
|
|
|
+ "No such schemes found on whitelist!");
|
|
|
return hosts
|
|
|
}
|
|
|
|
|
|
@@ -1078,13 +1092,13 @@ impl Hosts {
|
|
|
if n == 0 {
|
|
|
return vec![]
|
|
|
}
|
|
|
- trace!(target: "store::anchorlist_fetch_n_random_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_fetch_n_random_with_schemes()", "[START]");
|
|
|
|
|
|
// Retrieve all peers corresponding to that transport schemes
|
|
|
let hosts = self.anchorlist_fetch_with_schemes(schemes, None).await;
|
|
|
if hosts.is_empty() {
|
|
|
- debug!(target: "store::anchorlist_fetch_n_random_with_schemes",
|
|
|
- "No such schemes found on anchorlist!");
|
|
|
+ debug!(target: "net::hosts::store::anchorlist_fetch_n_random_with_schemes()",
|
|
|
+ "No such schemes found on anchorlist!");
|
|
|
return hosts
|
|
|
}
|
|
|
|
|
|
@@ -1122,8 +1136,8 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if ret.is_empty() {
|
|
|
- debug!(target: "store::greylist_fetch_excluding_schemes",
|
|
|
- "No such schemes found on greylist!")
|
|
|
+ debug!(target: "net::hosts::store::greylist_fetch_excluding_schemes()",
|
|
|
+ "No such schemes found on greylist!")
|
|
|
}
|
|
|
|
|
|
ret
|
|
|
@@ -1158,8 +1172,8 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if ret.is_empty() {
|
|
|
- debug!(target: "store::whiteist_fetch_excluding_schemes",
|
|
|
- "No such schemes found on whitelist!")
|
|
|
+ debug!(target: "net::hosts::store::whiteist_fetch_excluding_schemes()",
|
|
|
+ "No such schemes found on whitelist!")
|
|
|
}
|
|
|
|
|
|
ret
|
|
|
@@ -1176,14 +1190,14 @@ impl Hosts {
|
|
|
if n == 0 {
|
|
|
return vec![]
|
|
|
}
|
|
|
- trace!(target: "store::whitelist_fetch_excluding_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_excluding_schemes()", "[START]");
|
|
|
|
|
|
// Retrieve all peers not corresponding to that transport schemes
|
|
|
let hosts = self.whitelist_fetch_excluding_schemes(schemes, None).await;
|
|
|
|
|
|
if hosts.is_empty() {
|
|
|
- debug!(target: "store::whitelist_fetch_n_random_excluding_schemes",
|
|
|
- "No such schemes found on whitelist!");
|
|
|
+ debug!(target: "net::hosts::store::whitelist_fetch_n_random_excluding_schemes()",
|
|
|
+ "No such schemes found on whitelist!");
|
|
|
return hosts
|
|
|
}
|
|
|
|
|
|
@@ -1199,7 +1213,7 @@ impl Hosts {
|
|
|
schemes: &[String],
|
|
|
limit: Option<usize>,
|
|
|
) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store::greylist_fetch_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_with_schemes()", "[START]");
|
|
|
let greylist = self.greylist.read().await;
|
|
|
|
|
|
let mut limit = match limit {
|
|
|
@@ -1217,7 +1231,7 @@ impl Hosts {
|
|
|
ret.push((addr.clone(), *last_seen));
|
|
|
limit -= 1;
|
|
|
if limit == 0 {
|
|
|
- debug!(target: "store::greylist_fetch_with_schemes",
|
|
|
+ debug!(target: "net::hosts::store::greylist_fetch_with_schemes()",
|
|
|
"Found matching scheme, returning {} grey addresses",
|
|
|
ret.len());
|
|
|
return ret
|
|
|
@@ -1226,11 +1240,11 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if ret.is_empty() {
|
|
|
- debug!(target: "store::greylist_fetch_with_schemes",
|
|
|
+ debug!(target: "net::hosts::store::greylist_fetch_with_schemes()",
|
|
|
"No such schemes found on greylist!")
|
|
|
}
|
|
|
|
|
|
- trace!(target: "store::greylist_fetch_with_schemes", "END");
|
|
|
+ trace!(target: "net::hosts::store::greylist_fetch_with_schemes()", "END");
|
|
|
ret
|
|
|
}
|
|
|
|
|
|
@@ -1241,7 +1255,7 @@ impl Hosts {
|
|
|
schemes: &[String],
|
|
|
limit: Option<usize>,
|
|
|
) -> Vec<(Url, u64)> {
|
|
|
- trace!(target: "store::whitelist_fetch_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_with_schemes()", "[START]");
|
|
|
let whitelist = self.whitelist.read().await;
|
|
|
|
|
|
let mut limit = match limit {
|
|
|
@@ -1259,7 +1273,7 @@ impl Hosts {
|
|
|
ret.push((addr.clone(), *last_seen));
|
|
|
limit -= 1;
|
|
|
if limit == 0 {
|
|
|
- debug!(target: "store::whitelist_fetch_with_schemes",
|
|
|
+ debug!(target: "net::hosts::store::whitelist_fetch_with_schemes()",
|
|
|
"Found matching scheme, returning {} white addresses",
|
|
|
ret.len());
|
|
|
return ret
|
|
|
@@ -1268,11 +1282,11 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if ret.is_empty() {
|
|
|
- debug!(target: "store::whitelist_fetch_with_schemes",
|
|
|
+ debug!(target: "net::hosts::store::whitelist_fetch_with_schemes()",
|
|
|
"No such schemes found on whitelist!")
|
|
|
}
|
|
|
|
|
|
- trace!(target: "store::whitelist_fetch_with_schemes", "END");
|
|
|
+ trace!(target: "net::hosts::store::whitelist_fetch_with_schemes()", "END");
|
|
|
ret
|
|
|
}
|
|
|
|
|
|
@@ -1283,7 +1297,7 @@ impl Hosts {
|
|
|
schemes: &[String],
|
|
|
limit: Option<usize>,
|
|
|
) -> Vec<(Url, u64)> {
|
|
|
- //trace!(target: "store::anchorlist_fetch_with_schemes", "[START]");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_fetch_with_schemes()", "[START]");
|
|
|
let anchorlist = self.anchorlist.read().await;
|
|
|
|
|
|
let mut limit = match limit {
|
|
|
@@ -1301,8 +1315,8 @@ impl Hosts {
|
|
|
ret.push((addr.clone(), *last_seen));
|
|
|
limit -= 1;
|
|
|
if limit == 0 {
|
|
|
- debug!(target: "store::anchorlist_fetch_with_schemes",
|
|
|
- "Found matching scheme, returning {} anchor addresses",
|
|
|
+ debug!(target: "net::hosts::store::anchorlist_fetch_with_schemes()",
|
|
|
+ "Found matching scheme, returning {} anchor addresses",
|
|
|
ret.len());
|
|
|
return ret
|
|
|
}
|
|
|
@@ -1310,11 +1324,11 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if ret.is_empty() {
|
|
|
- warn!(target: "store::anchorlist_fetch_with_schemes",
|
|
|
- "No matching schemes found on anchorlist")
|
|
|
+ warn!(target: "net::hosts::store::anchorlist_fetch_with_schemes()",
|
|
|
+ "No matching schemes found on anchorlist")
|
|
|
}
|
|
|
|
|
|
- trace!(target: "store::anchorlist_fetch_with_schemes", "END");
|
|
|
+ trace!(target: "net::hosts::store::anchorlist_fetch_with_schemes", "END");
|
|
|
ret
|
|
|
}
|
|
|
|
|
|
@@ -1332,7 +1346,7 @@ impl Hosts {
|
|
|
|
|
|
let contents = load_file(&path);
|
|
|
if let Err(e) = contents {
|
|
|
- warn!(target: "store", "Failed retrieving saved hosts: {}", e);
|
|
|
+ warn!(target: "net::hosts::store::load_hosts()", "Failed retrieving saved hosts: {}", e);
|
|
|
return Ok(())
|
|
|
}
|
|
|
|
|
|
@@ -1342,7 +1356,7 @@ impl Hosts {
|
|
|
let url = match Url::parse(data[1]) {
|
|
|
Ok(u) => u,
|
|
|
Err(e) => {
|
|
|
- debug!(target: "store", "load_hosts(): Skipping malformed URL {}", e);
|
|
|
+ debug!(target: "net::hosts::store::load_hosts()", "Skipping malformed URL {}", e);
|
|
|
continue
|
|
|
}
|
|
|
};
|
|
|
@@ -1350,7 +1364,7 @@ impl Hosts {
|
|
|
let last_seen = match data[2].parse::<u64>() {
|
|
|
Ok(t) => t,
|
|
|
Err(e) => {
|
|
|
- debug!(target: "store", "load_hosts(): Skipping malformed last seen {}", e);
|
|
|
+ debug!(target: "net::hosts::store::load_hosts()", "Skipping malformed last seen {}", e);
|
|
|
continue
|
|
|
}
|
|
|
};
|
|
|
@@ -1366,7 +1380,7 @@ impl Hosts {
|
|
|
self.anchorlist_store(url, last_seen).await;
|
|
|
}
|
|
|
_ => {
|
|
|
- debug!(target: "store", "load_hosts(): Malformed list name...");
|
|
|
+ debug!(target: "net::hosts::store::load_hosts()", "Malformed list name...");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1401,10 +1415,10 @@ impl Hosts {
|
|
|
}
|
|
|
|
|
|
if !tsv.eq("") {
|
|
|
- info!(target: "store", "Saving hosts to: {:?}",
|
|
|
+ info!(target: "net::hosts::store::save_hosts()", "Saving hosts to: {:?}",
|
|
|
path);
|
|
|
if let Err(e) = save_file(&path, &tsv) {
|
|
|
- error!(target: "store", "Failed saving hosts: {}", e);
|
|
|
+ error!(target: "net::hosts::store::save_hosts()", "Failed saving hosts: {}", e);
|
|
|
}
|
|
|
}
|
|
|
|