Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gotatun/src/tun/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl IpSend for BufferedIpSend {
self.tx
.send(packet)
.await
.expect("receiver dropped after senders");
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions gotatun/src/tun/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl IpSend for TunChannelTx {
self.tun_tx_v4
.send(udp_packet)
.await
.expect("receiver exists");
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
}
Err(e) => tracing::trace!("Invalid UDP packet: {e:?}"),
}
Expand All @@ -82,7 +82,7 @@ impl IpSend for TunChannelTx {
self.tun_tx_v6
.send(udp_packet)
.await
.expect("receiver exists");
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
}
Err(e) => tracing::trace!("Invalid UDP packet: {e:?}"),
},
Expand Down
2 changes: 1 addition & 1 deletion gotatun/src/udp/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl UdpSend for BufferedUdpSend {
};
tx.send((packet, destination))
.await
.expect("receiver task is never stopped while Self exists");
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
Ok(())
}

Expand Down
22 changes: 18 additions & 4 deletions gotatun/src/udp/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ impl UdpSend for UdpChannelTx {
dest.port(),
&udp_payload,
);
self.udp_tx_v4.send(ipv4).await.expect("receiver exists");
self.udp_tx_v4
.send(ipv4)
.await
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
}
SocketAddr::V6(dest) => {
let ipv6 = create_ipv6_payload(
Expand All @@ -247,7 +250,10 @@ impl UdpSend for UdpChannelTx {
&udp_payload,
self.connection_id,
);
self.udp_tx_v6.send(ipv6).await.expect("receiver exists");
self.udp_tx_v6
.send(ipv6)
.await
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
}
};

Expand All @@ -258,7 +264,11 @@ impl UdpRecv for UdpChannelV4Rx {
type RecvManyBuf = ();

async fn recv_from(&mut self, _pool: &mut PacketBufPool) -> io::Result<(Packet, SocketAddr)> {
let ipv4 = self.udp_rx_v4.recv().await.expect("sender exists");
let ipv4 = self
.udp_rx_v4
.recv()
.await
.ok_or(io::Error::new(io::ErrorKind::BrokenPipe, "channel closed"))?;

let source_addr = ipv4.header.source();

Expand All @@ -277,7 +287,11 @@ impl UdpRecv for UdpChannelV6Rx {
type RecvManyBuf = ();

async fn recv_from(&mut self, _pool: &mut PacketBufPool) -> io::Result<(Packet, SocketAddr)> {
let ipv6 = self.udp_rx_v6.recv().await.expect("sender exists");
let ipv6 = self
.udp_rx_v6
.recv()
.await
.ok_or(io::Error::new(io::ErrorKind::BrokenPipe, "channel closed"))?;

let source_addr = ipv6.header.source();

Expand Down
Loading