diff --git a/crates/voelin-core/src/web.rs b/crates/voelin-core/src/web.rs index e464aba..c272023 100644 --- a/crates/voelin-core/src/web.rs +++ b/crates/voelin-core/src/web.rs @@ -1430,9 +1430,15 @@ pub(crate) mod tests { }; let mut port = [0u8; 2]; client.read_exact(&mut port).await.unwrap(); - let target = format!("{host}:{}", u16::from_be_bytes(port)); + let port = u16::from_be_bytes(port); + let target = format!("{host}:{port}"); targets.send(target.clone()).unwrap(); - let mut server = TcpStream::connect(target).await.unwrap(); + // The proxy resolves the name it is given (SOCKS5h). `localhost` is + // 127.0.0.1 to it, whatever this machine's resolver says: some answer + // `::1` only, and the servers of the tests listen on 127.0.0.1. + let dial = + if host == "localhost" { format!("127.0.0.1:{port}") } else { target }; + let mut server = TcpStream::connect(dial).await.unwrap(); client.write_all(&[5, 0, 0, 1, 0, 0, 0, 0, 0, 0]).await.unwrap(); let _ = tokio::io::copy_bidirectional(&mut client, &mut server).await; });