Explorar o código

net: Mark peer as rejected if we have missing dispatchers for certain packets.

parazyd %!s(int64=2) %!d(string=hai) anos
pai
achega
ee47552eee
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      src/net/channel.rs

+ 10 - 0
src/net/channel.rs

@@ -293,6 +293,16 @@ impl Channel {
                 // If we're getting messages without dispatchers, it's spam.
                 Err(Error::MissingDispatcher) => {
                     debug!(target: "net::channel::main_receive_loop()", "Stopping channel {:?}", self);
+
+                    // We will reject further connections from this peer
+                    self.session
+                        .upgrade()
+                        .unwrap()
+                        .p2p()
+                        .hosts()
+                        .mark_rejected(self.address())
+                        .await;
+
                     return Err(Error::ChannelStopped)
                 }
                 Err(_) => unreachable!("You added a new error in notify()"),