diff --git a/easytier/src/connector/udp_hole_punch.rs b/easytier/src/connector/udp_hole_punch.rs index 89b1e3d..d8851ce 100644 --- a/easytier/src/connector/udp_hole_punch.rs +++ b/easytier/src/connector/udp_hole_punch.rs @@ -438,12 +438,12 @@ impl UdpHolePunchRpc for UdpHolePunchRpcService { } // send max k1 packets if we are predicting the dst port - let max_k1 = 60; + let max_k1 = 180; // send max k2 packets if we are sending to random port let max_k2 = rand::thread_rng().gen_range(600..800); // this means the NAT is allocating port in a predictable way - if max_port.abs_diff(min_port) <= 3 * max_k1 && round <= 6 && punch_predictablely { + if max_port.abs_diff(min_port) <= max_k1 && round <= 6 && punch_predictablely { let (min_port, max_port) = { // round begin from 0. if round is even, we guess port in increasing order let port_delta = (max_k1 as u32) / ip_count as u32; @@ -879,7 +879,7 @@ impl UdpHolePunchConnector { let mut last_port_idx = rand::thread_rng().gen_range(0..data.shuffled_port_vec.len()); - for round in 0..5 { + for round in 0..30 { let ret = rpc_stub .try_punch_symmetric( BaseController {}, diff --git a/easytier/src/gateway/udp_proxy.rs b/easytier/src/gateway/udp_proxy.rs index 8307dcf..18e382e 100644 --- a/easytier/src/gateway/udp_proxy.rs +++ b/easytier/src/gateway/udp_proxy.rs @@ -182,7 +182,7 @@ impl UdpNatEntry { &mut buf, &src_v4, len, - 1256, + 1200, ip_id, ) .await @@ -350,7 +350,7 @@ impl UdpProxy { peer_manager: Arc, ) -> Result, Error> { let cidr_set = CidrSet::new(global_ctx.clone()); - let (sender, receiver) = channel(64); + let (sender, receiver) = channel(1024); let ret = Self { global_ctx, peer_manager, diff --git a/easytier/src/tunnel/ring.rs b/easytier/src/tunnel/ring.rs index c382c7d..7394932 100644 --- a/easytier/src/tunnel/ring.rs +++ b/easytier/src/tunnel/ring.rs @@ -26,7 +26,7 @@ use super::{ StreamItem, Tunnel, TunnelConnector, TunnelError, TunnelInfo, TunnelListener, }; -static RING_TUNNEL_CAP: usize = 64; +static RING_TUNNEL_CAP: usize = 128; static RING_TUNNEL_RESERVERD_CAP: usize = 4; type RingLock = parking_lot::Mutex<()>; diff --git a/easytier/src/tunnel/udp.rs b/easytier/src/tunnel/udp.rs index bde119e..df96ec2 100644 --- a/easytier/src/tunnel/udp.rs +++ b/easytier/src/tunnel/udp.rs @@ -293,8 +293,8 @@ impl UdpTunnelListenerData { return; } - let ring_for_send_udp = Arc::new(RingTunnel::new(32)); - let ring_for_recv_udp = Arc::new(RingTunnel::new(32)); + let ring_for_send_udp = Arc::new(RingTunnel::new(64)); + let ring_for_recv_udp = Arc::new(RingTunnel::new(64)); tracing::debug!( ?ring_for_send_udp, ?ring_for_recv_udp,