diff --git a/README.md b/README.md index dbd6794..6fa7efe 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,4 @@ Sandhole is in active development. Contributions are welcome, but try it in prod - [rlt](https://github.com/kaichaosun/rlt) - Uses localtunnel's protocol instead of SSH. Written in Rust. - [wstunnel](https://github.com/erebe/wstunnel) - Uses its WebSocket-based protocol instead of SSH. Written in Rust. - [rathole](https://github.com/rathole-org/rathole) - A highly configurable reverse proxy with NAT traversal and a great name. Written in Rust. -- [sshuttle](https://github.com/sshuttle/sshuttle) - A smarter proxy service, also based on SSH, that only needs Python in the server. Written in Python. +- [sshuttle](https://github.com/sshuttle/sshuttle) - A smart proxy service, also based on SSH, that only needs Python in the server. Written in Python. diff --git a/src/entrypoint.rs b/src/entrypoint.rs index 327132a..51ece82 100644 --- a/src/entrypoint.rs +++ b/src/entrypoint.rs @@ -851,7 +851,6 @@ async fn handle_https_connection( proxy_data, ssh_config, mut sandhole, - #[cfg_attr(not(feature = "acme"), expect(unused_variables))] certificates, http2_server_config, http11_server_config, @@ -889,6 +888,8 @@ async fn handle_https_connection( } return; } + #[cfg(not(feature = "acme"))] + let _ = certificates; let ip = address.ip().to_canonical(); if let Some(tunnel_handler) = sandhole.sni.get(&sni, ip) { let Ok(mut channel) = tunnel_handler.tunneling_channel(ip, address.port()).await else { diff --git a/tests/tcp_bind_random_ports.rs b/tests/tcp_bind_random_ports.rs index df0c68a..17a26e7 100644 --- a/tests/tcp_bind_random_ports.rs +++ b/tests/tcp_bind_random_ports.rs @@ -85,7 +85,7 @@ async fn tcp_bind_random_ports() { .tcpip_forward("", 12345) .await .expect("tcpip_forward failed"); - let regex = regex::Regex::new(r"foobar.tld:(\d+)").expect("Invalid regex"); + let regex = regex::Regex::new(r"foobar\.tld:(\d+)").expect("Invalid regex"); let Ok(port) = timeout(Duration::from_secs(3), async move { while let Some(message) = channel.wait().await { match message { diff --git a/tests/tcp_multi_stream_download.rs b/tests/tcp_multi_stream_download.rs index 29032fe..df5bdc6 100644 --- a/tests/tcp_multi_stream_download.rs +++ b/tests/tcp_multi_stream_download.rs @@ -1,5 +1,6 @@ use std::{sync::Arc, time::Duration}; +use bytes::BytesMut; use clap::Parser; use rand::RngCore; use russh::{ @@ -118,6 +119,7 @@ async fn tcp_multi_stream_download() { .await .unwrap(); write_half.write_all(&data[..file_size]).await.unwrap(); + write_half.flush().await.unwrap(); }); let jh = tokio::spawn(async move { let mut buf = [0u8; size_of::()]; @@ -160,14 +162,16 @@ impl russh::client::Handler for SshClient { let mut stream = channel.into_stream(); stream.read_exact(&mut len_buf).await.unwrap(); let mut size = usize::from_le_bytes(len_buf); - let mut buf = [0u8; 64_000]; - while let Ok(n) = stream.read(&mut buf).await { + let mut buf = BytesMut::new(); + while let Ok(n) = stream.read_buf(&mut buf).await { + buf.truncate(0); size = size.saturating_sub(n); if size == 0 { break; } } stream.write_all(&len_buf[..]).await.unwrap(); + stream.flush().await.unwrap(); }); Ok(()) }