Update handshake deserialize to error on wrong messages
This commit is contained in:
parent
56527ae8d7
commit
5a12095959
1 changed files with 9 additions and 6 deletions
|
|
@ -531,12 +531,15 @@ impl Handshake<ByteBuf<'static>> {
|
||||||
expected_len,
|
expected_len,
|
||||||
"handshake",
|
"handshake",
|
||||||
))?;
|
))?;
|
||||||
Ok((
|
let h = Self::bopts()
|
||||||
Self::bopts()
|
.deserialize::<Handshake<ByteBuf<'_>>>(hbuf)
|
||||||
.deserialize(hbuf)
|
.map_err(|e| MessageDeserializeError::Other(e.into()))?;
|
||||||
.map_err(|e| MessageDeserializeError::Other(e.into()))?,
|
if h.pstr.0 != PSTR_BT1.as_bytes() {
|
||||||
expected_len,
|
return Err(MessageDeserializeError::Other(anyhow::anyhow!(
|
||||||
))
|
"pstr doesn't match bittorrent V1"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
Ok((h, expected_len))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue