Description:
The scanner panics and crashes whenever it encounters network errors like Connection timed out or Connection refused. This happens because of an unhandled .unwrap() call in src/scanning/mod.rs.
Log output:
Plaintext
thread 'tokio-rt-worker' panicked at src/scanning/mod.rs:16:59:
called Result::unwrap() on an Err value: Os { code: 110, kind: TimedOut, message: "Connection timed out" }
Proposed Fix:
Since I am not an experienced Rust developer, I asked an AI for assistance to make the scanner more resilient. Replacing the .unwrap() with proper error handling solves the crash.
Here is the suggested change in src/scanning/mod.rs:
// Replace this:
let mut stream = TcpStream::connect(socket).await.unwrap();
// With this:
let mut stream = TcpStream::connect(socket)
.await
.map_err(|e| anyhow::anyhow!("Connection failed: {}", e))?;
This ensures that network errors are caught as anyhow::Result instead of panicking the entire application.
Description:
The scanner panics and crashes whenever it encounters network errors like Connection timed out or Connection refused. This happens because of an unhandled .unwrap() call in src/scanning/mod.rs.
Log output:
Plaintext
thread 'tokio-rt-worker' panicked at src/scanning/mod.rs:16:59:
called
Result::unwrap()on anErrvalue: Os { code: 110, kind: TimedOut, message: "Connection timed out" }Proposed Fix:
Since I am not an experienced Rust developer, I asked an AI for assistance to make the scanner more resilient. Replacing the .unwrap() with proper error handling solves the crash.
Here is the suggested change in src/scanning/mod.rs:
// Replace this:
let mut stream = TcpStream::connect(socket).await.unwrap();
// With this:
let mut stream = TcpStream::connect(socket)
.await
.map_err(|e| anyhow::anyhow!("Connection failed: {}", e))?;
This ensures that network errors are caught as anyhow::Result instead of panicking the entire application.