disconnect peers that send bad data

This commit is contained in:
Igor Katson 2024-03-29 20:40:05 +00:00
parent cee66309d0
commit ef44f104a5
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5

View file

@ -1397,11 +1397,15 @@ impl PeerHandler {
self.state.maybe_transmit_haves(chunk_info.piece_index);
}
false => {
warn!("checksum for piece={} did not validate", index,);
warn!(
"checksum for piece={} did not validate. disconecting peer.",
index
);
self.state
.lock_write("mark_piece_broken")
.get_chunks_mut()?
.mark_piece_broken_if_not_have(chunk_info.piece_index);
anyhow::bail!("i am probably a bogus peer. dying.")
}
};
Ok::<_, anyhow::Error>(())