diff --git a/rust/src/bittorrent_dht/bittorrent_dht.rs b/rust/src/bittorrent_dht/bittorrent_dht.rs index 346635714f..0e0d77fd87 100644 --- a/rust/src/bittorrent_dht/bittorrent_dht.rs +++ b/rust/src/bittorrent_dht/bittorrent_dht.rs @@ -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;