From 60e6ed2c895f0e7f6dd38182e5101068d08e0661 Mon Sep 17 00:00:00 2001 From: monosans Date: Tue, 24 Jun 2025 08:41:59 +0300 Subject: [PATCH] fix socks5 checking panic Fixes #661 --- src/checker.rs | 15 +++++++++++++-- src/main.rs | 2 +- src/scraper.rs | 4 ++-- src/tui.rs | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/checker.rs b/src/checker.rs index e212c25..09c9e5d 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -64,8 +64,19 @@ pub async fn check_all( } while let Some(res) = join_set.join_next().await { - res.wrap_err("failed to join proxy checking task")? - .wrap_err("proxy checking worker failed")?; + match res { + Ok(Ok(())) => {} + Ok(Err(e)) => { + return Err(e).wrap_err("proxy checking task failed"); + } + Err(e) => { + if e.is_panic() { + tracing::error!("proxy checking task panicked: {}", e); + } else { + tracing::error!("proxy checking task was cancelled: {}", e); + } + } + } } Ok(Arc::into_inner(checked_proxies) diff --git a/src/main.rs b/src/main.rs index 372f973..dbcb078 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,7 +161,7 @@ async fn main() -> color_eyre::Result<()> { drop(http_client); while let Some(task) = output_dependencies_tasks.join_next().await { - task.wrap_err("failed to join output dependencies task")??; + task.wrap_err("output dependencies task panicked or was cancelled")??; } drop(output_dependencies_tasks); diff --git a/src/scraper.rs b/src/scraper.rs index c028899..13046f9 100644 --- a/src/scraper.rs +++ b/src/scraper.rs @@ -153,8 +153,8 @@ pub async fn scrape_all( } while let Some(res) = join_set.join_next().await { - res.wrap_err("failed to join proxy scrape task")? - .wrap_err("proxy scrape task failed")?; + res.wrap_err("proxy scraping task panicked or was cancelled")? + .wrap_err("proxy scraping task failed")?; } Ok(Arc::into_inner(proxies) diff --git a/src/tui.rs b/src/tui.rs index 661bf15..ce0717a 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -78,7 +78,7 @@ impl Tui { } drop(rx); while let Some(task) = join_set.join_next().await { - task.wrap_err("failed to join event listener task")? + task.wrap_err("event listener task panicked or was cancelled")? .wrap_err("event listener task failed")?; } Ok(())