Whoops! Missed a reserved byte in client requests.

This commit is contained in:
2021-11-21 21:07:30 -08:00
parent c05b0f2b74
commit 774591cb54
2 changed files with 13 additions and 3 deletions

View File

@@ -32,9 +32,9 @@ impl ClientConnectionRequest {
pub async fn read<R: AsyncRead + Send + Unpin>(
r: &mut R,
) -> Result<Self, DeserializationError> {
let mut buffer = [0; 2];
let mut buffer = [0; 3];
read_amt(r, 2, &mut buffer).await?;
read_amt(r, 3, &mut buffer).await?;
if buffer[0] != 5 {
return Err(DeserializationError::InvalidVersion(5, buffer[0]));
@@ -47,6 +47,10 @@ impl ClientConnectionRequest {
x => return Err(DeserializationError::InvalidClientCommand(x)),
};
if buffer[2] != 0 {
return Err(DeserializationError::InvalidReservedByte(buffer[2]));
}
let destination_address = SOCKSv5Address::read(r).await?;
read_amt(r, 2, &mut buffer).await?;
@@ -69,7 +73,7 @@ impl ClientConnectionRequest {
ClientConnectionCommand::AssociateUDPPort => 3,
};
w.write_all(&[5, command]).await?;
w.write_all(&[5, command, 0]).await?;
self.destination_address.write(w).await?;
w.write_all(&[
(self.destination_port >> 8) as u8,