mirror of
https://github.com/dndx/phantun.git
synced 2025-10-15 18:25:36 +08:00
fix(phantun) better UDP error handling
When UDP send fails, print a proper error message and close the connection, instead of `panic`ing.
This commit is contained in:
@@ -139,7 +139,11 @@ async fn main() {
|
||||
match res {
|
||||
Some(size) => {
|
||||
if size > 0 {
|
||||
udp_sock.send(&buf_tcp[..size]).await.unwrap();
|
||||
if let Err(e) = udp_sock.send(&buf_tcp[..size]).await {
|
||||
connections.write().await.remove(&addr);
|
||||
error!("Unable to send UDP packet to {}: {}, closing connection", e, addr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
|
Reference in New Issue
Block a user