Sfoglia il codice sorgente

hosts: more permissive transitions from HostState::Free

This was a bug regarding the following state transition functions:

Free -> Connected
Free -> Move

Inbound connections go directly to Connected (1) and Move (2) in the
following cases- when an inbound connection connects to us (1), when we
blacklist a peer due to missing dispatchers (2).

If we previously had a connection on the same port that was now marked
as HostState::Free in the hostregistry, this would create a panic.
draoi 2 anni fa
parent
commit
3c526d179f
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      src/net/hosts.rs

+ 2 - 2
src/net/hosts.rs

@@ -214,7 +214,7 @@ impl HostState {
             HostState::Suspend => Err(Error::HostStateBlocked(start, end)),
             HostState::Suspend => Err(Error::HostStateBlocked(start, end)),
             HostState::Connected(_) => Err(Error::HostStateBlocked(start, end)),
             HostState::Connected(_) => Err(Error::HostStateBlocked(start, end)),
             HostState::Move => Ok(HostState::Connected(channel)),
             HostState::Move => Ok(HostState::Connected(channel)),
-            HostState::Free(_) => Err(Error::HostStateBlocked(start, end)),
+            HostState::Free(_) => Ok(HostState::Connected(channel)),
         }
         }
     }
     }
 
 
@@ -231,7 +231,7 @@ impl HostState {
             HostState::Suspend => Err(Error::HostStateBlocked(start, end)),
             HostState::Suspend => Err(Error::HostStateBlocked(start, end)),
             HostState::Connected(_) => Ok(HostState::Move),
             HostState::Connected(_) => Ok(HostState::Move),
             HostState::Move => Err(Error::HostStateBlocked(start, end)),
             HostState::Move => Err(Error::HostStateBlocked(start, end)),
-            HostState::Free(_) => Err(Error::HostStateBlocked(start, end)),
+            HostState::Free(_) => Ok(HostState::Move),
         }
         }
     }
     }