connect_via_proxy: Actually send initial handshake.

Our previous code would make a TCP connection to the proxy, then
wait forever for it to say something. Whoops!

Part of a fix for #676.
This commit is contained in:
Nick Mathewson 2022-11-30 11:49:17 -05:00
parent 4afe128189
commit 475d9af34a
1 changed files with 3 additions and 3 deletions

View File

@ -108,9 +108,6 @@ pub(crate) async fn connect_via_proxy<R: TcpProvider + Send + Sync>(
let mut inbuf = [0_u8; 1024];
let mut n_read = 0;
let reply = loop {
// Read some more stuff.
n_read += stream.read(&mut inbuf[n_read..]).await?;
// try to advance the handshake to the next state.
let action = match handshake.handshake(&inbuf[..n_read]) {
Err(_) => {
@ -142,6 +139,9 @@ pub(crate) async fn connect_via_proxy<R: TcpProvider + Send + Sync>(
if action.finished {
break handshake.into_reply();
}
// Read some more stuff.
n_read += stream.read(&mut inbuf[n_read..]).await?;
};
let status = reply