Merge pull request #135 from ZcashFoundation/130

On receipt of a Filter(Load|Add|Clear) message, disconnect from peer
This commit is contained in:
Deirdre Connolly 2019-12-05 14:06:05 -05:00 committed by GitHub
parent d559a3fa52
commit 82e246d87b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -40,6 +40,10 @@ pub enum PeerError {
/// to shed load.
#[error("Internal services over capacity")]
Overloaded,
/// A peer sent us a message we don't support or instructed to
/// disconnect from upon receipt.
#[error("Remote peer sent an unsupported message type.")]
UnsupportedMessage,
/// We got a `Reject` message. This does not necessarily mean that
/// the peer connection is in a bad state, but for the time being
/// we are considering it a PeerError.

View File

@ -325,6 +325,18 @@ where
_ => {}
}
// Per BIP-011, since we don't advertise NODE_BLOOM, we MUST
// disconnect from this peer immediately.
match msg {
Message::FilterLoad { .. }
| Message::FilterAdd { .. }
| Message::FilterClear { .. } => {
self.fail_with(PeerError::UnsupportedMessage);
return;
}
_ => {}
}
// Interpret `msg` as a request from the remote peer to our node,
// and try to construct an appropriate request object.
let req = match msg {