Support multiple source/dest addresses - #32
Conversation
| }) | ||
| }) | ||
| .collect::<JoinSet<_>>(); | ||
| join_set.join_next().await.unwrap().unwrap().unwrap() |
There was a problem hiding this comment.
reported by reviewdog 🐶
[semgrep] expect or unwrap called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
There was a problem hiding this comment.
I kinda agree with semgrep here. The current code doesn't actually exit through this path, but the unwraps are hard to follow. It also seems odd to exit after the first task without waiting for the others to complete (future, hypothetical) cleanup. What about something like
// Wait until all listening tasks exit...
while let Some(task) = join_set.join_next().await {
let _ = task.context("Listener task error")?;
info!("Listener task completed ok");
}
Ok(())There was a problem hiding this comment.
The current code doesn't actually exit through this path, but the unwraps are hard to follow
Replaced the unwraps with expects to add more context on the errors that are being managed. They are placed there to handle a condition that wouldn't happen at all (the JoinSet being empty), or panics within the forwarding tasks themselves. The actual anyhow Result is still returned to the main function.
What about something like
A 'successful' task will never actually complete, it will continue to forward requests indefinitely. I added a subsequent 'shutdown' call to abort all other tasks when an error is encountered.
9b1665a to
82f8b25
Compare
82f8b25 to
a4c3665
Compare
No description provided.