diff --git a/client/src/relay/connection.rs b/client/src/relay/connection.rs index 81a119d..9d1022d 100644 --- a/client/src/relay/connection.rs +++ b/client/src/relay/connection.rs @@ -75,6 +75,8 @@ pub async fn manage_connection( } } + new_conn.update_max_udp_relay_packet_size(); + // connection established, drop the lock implicitly break new_conn; }; @@ -247,12 +249,15 @@ impl Connection { } pub fn update_max_udp_relay_packet_size(&self) { - let size = match self.controller.max_datagram_size() { - Some(size) => size, - None => { - log::warn!("[relay] [connection] Failed to detect the max datagram size"); - 65535 - } + let size = match self.udp_relay_mode { + UdpRelayMode::Native(()) => match self.controller.max_datagram_size() { + Some(size) => size, + None => { + log::warn!("[relay] [connection] Failed to detect the max datagram size"); + 65535 + } + }, + UdpRelayMode::Quic(()) => 65535, }; super::MAX_UDP_RELAY_PACKET_SIZE.store(size, Ordering::Release); diff --git a/client/src/relay/request.rs b/client/src/relay/request.rs index 2e39fa9..030a78a 100644 --- a/client/src/relay/request.rs +++ b/client/src/relay/request.rs @@ -58,8 +58,6 @@ async fn process_request( } => { conn.udp_sessions().insert(assoc_id, pkt_recv_tx); while let Some((pkt, addr)) = pkt_send_rx.recv().await { - conn.update_max_udp_relay_packet_size(); - tokio::spawn(conn.clone().handle_packet_to( assoc_id, pkt, diff --git a/client/src/relay/task.rs b/client/src/relay/task.rs index f7383c0..eac934d 100644 --- a/client/src/relay/task.rs +++ b/client/src/relay/task.rs @@ -74,6 +74,7 @@ impl Connection { Ok(()) } + self.update_max_udp_relay_packet_size(); let display_addr = format!("{addr}"); match send_packet(self, assoc_id, pkt, addr, mode).await { @@ -87,6 +88,7 @@ impl Connection { } pub async fn handle_packet_from(self, assoc_id: u32, pkt: Bytes, addr: Address) { + self.update_max_udp_relay_packet_size(); let display_addr = format!("{addr}"); if let Some(recv_pkt_tx) = self.udp_sessions().get(&assoc_id) {