drop msgs received from a banned peer (#886)

This commit is contained in:
Antioch Peverell
2018-03-27 12:09:41 -04:00
committed by GitHub
parent 5bd0c251dc
commit 4fcf5fdbca
5 changed files with 32 additions and 0 deletions
+13
View File
@@ -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()?;