nat: waiting for available capacity instead of dropping downlink packets

This commit is contained in:
eric committed 2021-02-15 14:50:25 +08:00
1 parent 8154f5c2e1
commit cff7a9b47e
2 files changed
+5 -2

No files matched your search

+3 -1
View File
@@ -166,11 +166,13 @@ impl NatManager {
src_addr: Some(addr.clone()),
dst_addr: Some(SocksAddr::from(raddr)),
};
if let Err(err) = client_ch_tx.try_send(pkt) {
if let Err(err) = client_ch_tx.send(pkt).await {
debug!(
"send downlink packet failed {} -> {}: {}",
&addr, &raddr, err
);
sessions.lock().await.remove(&raddr);
break;
}
// activity update
+2 -1
View File
@@ -141,10 +141,11 @@ impl NetStackImpl {
let fakedns2 = fakedns.clone();
let pcb = listener.pcb();
// Sending packets to TUN should be very fast.
let (client_ch_tx, mut client_ch_rx): (
TokioSender<UdpPacket>,
TokioReceiver<UdpPacket>,
) = tokio_channel(100);
) = tokio_channel(32);
// downlink
let lwip_lock2 = lwip_lock.clone();