diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 9d3d9014538..b5ac5a48fdd 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -1993,7 +1993,6 @@ where Ok(KademliaHandler::new( KademliaHandlerConfig { protocol_config: self.protocol_config.clone(), - allow_listening: true, idle_timeout: self.connection_idle_timeout, }, ConnectedPoint::Listener { @@ -2014,7 +2013,6 @@ where Ok(KademliaHandler::new( KademliaHandlerConfig { protocol_config: self.protocol_config.clone(), - allow_listening: true, idle_timeout: self.connection_idle_timeout, }, ConnectedPoint::Dialer { diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 27938c1f477..2067b381103 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -106,9 +106,6 @@ pub struct KademliaHandlerConfig { /// Configuration of the wire protocol. pub protocol_config: KademliaProtocolConfig, - /// If false, we deny incoming requests. - pub allow_listening: bool, - /// Time after which we close an idle connection. pub idle_timeout: Duration, } @@ -534,13 +531,6 @@ where ::InboundOpenInfo, >, ) { - // If `self.allow_listening` is false, then we produced a `DeniedUpgrade` and `protocol` - // is a `Void`. - let protocol = match protocol { - future::Either::Left(p) => p, - future::Either::Right(p) => void::unreachable(p), - }; - if let ProtocolStatus::Unconfirmed = self.protocol_status { // Upon the first successfully negotiated substream, we know that the // remote is configured with the same protocol name and we want @@ -572,7 +562,6 @@ where } } - debug_assert!(self.config.allow_listening); let connec_unique_id = self.next_connec_unique_id; self.next_connec_unique_id.0 += 1; self.inbound_substreams @@ -611,19 +600,14 @@ where type InEvent = KademliaHandlerIn; type OutEvent = KademliaHandlerEvent; type Error = io::Error; // TODO: better error type? - type InboundProtocol = Either; + type InboundProtocol = KademliaProtocolConfig; type OutboundProtocol = KademliaProtocolConfig; // Message of the request to send to the remote, and user data if we expect an answer. type OutboundOpenInfo = (KadRequestMsg, Option); type InboundOpenInfo = (); fn listen_protocol(&self) -> SubstreamProtocol { - if self.config.allow_listening { - SubstreamProtocol::new(self.config.protocol_config.clone(), ()) - .map_upgrade(Either::Left) - } else { - SubstreamProtocol::new(Either::Right(upgrade::DeniedUpgrade), ()) - } + SubstreamProtocol::new(self.config.protocol_config.clone(), ()) } fn on_behaviour_event(&mut self, message: KademliaHandlerIn) { @@ -812,7 +796,6 @@ impl Default for KademliaHandlerConfig { fn default() -> Self { KademliaHandlerConfig { protocol_config: Default::default(), - allow_listening: true, idle_timeout: Duration::from_secs(10), } }