drop msgs received from a banned peer (#886)
This commit is contained in:
@@ -41,6 +41,19 @@ impl MessageHandler for Protocol {
|
||||
fn consume<'a>(&self, mut msg: Message<'a>) -> Result<Option<Response<'a>>, Error> {
|
||||
let adapter = &self.adapter;
|
||||
|
||||
// If we received a msg from a banned peer then log and drop it.
|
||||
// If we are getting a lot of these then maybe we are not cleaning
|
||||
// banned peers up correctly?
|
||||
if adapter.is_banned(self.addr.clone()) {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"handler: consume: peer {:?} banned, received: {:?}, dropping.",
|
||||
self.addr,
|
||||
msg.header.msg_type,
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
match msg.header.msg_type {
|
||||
Type::Ping => {
|
||||
let ping: Ping = msg.body()?;
|
||||
|
||||
Reference in New Issue
Block a user