1
0

stop restricting packet size in relay mode Quic

This commit is contained in:
EAimTY 2022-06-25 19:51:47 +09:00
parent 87837ca068
commit 5e6ab51e5d
3 changed files with 13 additions and 8 deletions

View File

@ -75,6 +75,8 @@ pub async fn manage_connection(
} }
} }
new_conn.update_max_udp_relay_packet_size();
// connection established, drop the lock implicitly // connection established, drop the lock implicitly
break new_conn; break new_conn;
}; };
@ -247,12 +249,15 @@ impl Connection {
} }
pub fn update_max_udp_relay_packet_size(&self) { pub fn update_max_udp_relay_packet_size(&self) {
let size = match self.controller.max_datagram_size() { let size = match self.udp_relay_mode {
UdpRelayMode::Native(()) => match self.controller.max_datagram_size() {
Some(size) => size, Some(size) => size,
None => { None => {
log::warn!("[relay] [connection] Failed to detect the max datagram size"); log::warn!("[relay] [connection] Failed to detect the max datagram size");
65535 65535
} }
},
UdpRelayMode::Quic(()) => 65535,
}; };
super::MAX_UDP_RELAY_PACKET_SIZE.store(size, Ordering::Release); super::MAX_UDP_RELAY_PACKET_SIZE.store(size, Ordering::Release);

View File

@ -58,8 +58,6 @@ async fn process_request(
} => { } => {
conn.udp_sessions().insert(assoc_id, pkt_recv_tx); conn.udp_sessions().insert(assoc_id, pkt_recv_tx);
while let Some((pkt, addr)) = pkt_send_rx.recv().await { while let Some((pkt, addr)) = pkt_send_rx.recv().await {
conn.update_max_udp_relay_packet_size();
tokio::spawn(conn.clone().handle_packet_to( tokio::spawn(conn.clone().handle_packet_to(
assoc_id, assoc_id,
pkt, pkt,

View File

@ -74,6 +74,7 @@ impl Connection {
Ok(()) Ok(())
} }
self.update_max_udp_relay_packet_size();
let display_addr = format!("{addr}"); let display_addr = format!("{addr}");
match send_packet(self, assoc_id, pkt, addr, mode).await { 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) { 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}"); let display_addr = format!("{addr}");
if let Some(recv_pkt_tx) = self.udp_sessions().get(&assoc_id) { if let Some(recv_pkt_tx) = self.udp_sessions().get(&assoc_id) {