diff --git a/src/main.rs b/src/main.rs index 79b0eb1..022734b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -852,7 +852,13 @@ async fn main() { _ => panic!("invalid protocol for dns resolver"), }; let sock = match resolver.host().unwrap() { - Host::Domain(_) => panic!("Dns resolver must be an ip address"), + Host::Domain(host) => match Host::parse(host) { + Ok(Host::Ipv4(ip)) => SocketAddr::V4(SocketAddrV4::new(ip, port)), + Ok(Host::Ipv6(ip)) => SocketAddr::V6(SocketAddrV6::new(ip, port, 0, 0)), + Ok(Host::Domain(_)) | Err(_) => { + panic!("Dns resolver must be an ip address, got {}", host) + } + }, Host::Ipv4(ip) => SocketAddr::V4(SocketAddrV4::new(ip, port)), Host::Ipv6(ip) => SocketAddr::V6(SocketAddrV6::new(ip, port, 0, 0)), }; diff --git a/src/tunnel/io.rs b/src/tunnel/io.rs index 48f1c4d..607d09e 100644 --- a/src/tunnel/io.rs +++ b/src/tunnel/io.rs @@ -1,4 +1,3 @@ -use std::cmp::max; use fastwebsockets::{Frame, OpCode, Payload, WebSocketError, WebSocketRead, WebSocketWrite}; use futures_util::{pin_mut, FutureExt}; use hyper::upgrade::Upgraded; @@ -23,7 +22,7 @@ pub(super) async fn propagate_read( }); static MAX_PACKET_LENGTH: usize = 64 * 1024; - let mut buffer = vec![0u8; MAX_PACKET_LENGTH * 1]; + let mut buffer = vec![0u8; MAX_PACKET_LENGTH]; // We do our own pin_mut! to avoid shadowing timeout and be able to reset it, on next loop iteration // We reuse the future to avoid creating a timer in the tight loop @@ -77,7 +76,13 @@ pub(super) async fn propagate_read( let new_size = buffer.capacity() + (buffer.capacity() / 4); // grow buffer by 1.25 % buffer.reserve_exact(new_size); buffer.resize(buffer.capacity(), 0); - //info!("Buffer {} Mb {} {} {}", buffer.capacity() as f64 / 1024.0 / 1024.0, new_size, buffer.as_slice().len(), buffer.capacity()) + trace!( + "Buffer {} Mb {} {} {}", + buffer.capacity() as f64 / 1024.0 / 1024.0, + new_size, + buffer.as_slice().len(), + buffer.capacity() + ) } } diff --git a/src/tunnel/server.rs b/src/tunnel/server.rs index 9a573d7..909fdf5 100644 --- a/src/tunnel/server.rs +++ b/src/tunnel/server.rs @@ -351,7 +351,7 @@ async fn server_upgrade(server_config: Arc, mut req: Request