bittorrent-dht: only attempt to parse dht messages

The bittorrent flow is shared with transport messages as well as dht
messages. Only attempt to parse dht message as dht, ignore the rest.
pull/8113/head
Jason Ish 3 years ago committed by Victor Julien
parent 98a9391210
commit 5a30ee77a1

@ -92,7 +92,21 @@ impl BitTorrentDHTState {
return tx;
}
fn is_dht(input: &[u8]) -> bool {
if input.len() > 5 {
match &input[0..5] {
b"d1:ad" | b"d1:rd" | b"d2:ip" | b"d1:el" => true,
_ => false,
}
} else {
false
}
}
pub fn parse(&mut self, input: &[u8]) -> bool {
if !Self::is_dht(input) {
return true;
}
let mut tx = self.new_tx();
let mut status = true;

Loading…
Cancel
Save