Просмотр исходного кода

refine_session: actually delete greylist entries that fail the handshake

draoi 2 лет назад
Родитель
Сommit
1d8ab03f80
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      src/net/session/refine_session.rs

+ 4 - 2
src/net/session/refine_session.rs

@@ -268,7 +268,6 @@ impl GreylistRefinery {
             match hosts.container.fetch_random_with_schemes(HostColor::Grey, &allowed_transports) {
             match hosts.container.fetch_random_with_schemes(HostColor::Grey, &allowed_transports) {
                 Some((entry, _)) => {
                 Some((entry, _)) => {
                     let url = &entry.0;
                     let url = &entry.0;
-                    let last_seen = &entry.1;
 
 
                     if let Err(e) = hosts.try_register(url.clone(), HostState::Refine) {
                     if let Err(e) = hosts.try_register(url.clone(), HostState::Refine) {
                         debug!(target: "net::refinery", "Unable to refine addr={}, err={}",
                         debug!(target: "net::refinery", "Unable to refine addr={}, err={}",
@@ -277,12 +276,15 @@ impl GreylistRefinery {
                     }
                     }
 
 
                     if !self.session().handshake_node(url.clone(), self.p2p().clone()).await {
                     if !self.session().handshake_node(url.clone(), self.p2p().clone()).await {
+                        hosts.container.remove_if_exists(HostColor::Grey, url);
+
                         debug!(
                         debug!(
                             target: "net::refinery",
                             target: "net::refinery",
                             "Peer {} handshake failed. Removed from greylist", url,
                             "Peer {} handshake failed. Removed from greylist", url,
                         );
                         );
 
 
-                        hosts.greylist_host(url, *last_seen).unwrap();
+                        // Free up this addr for future operations.
+                        hosts.unregister(url);
 
 
                         continue
                         continue
                     }
                     }