Fixes #819 - tlsx hangs indefinitely when scanning large target lists (~25k+ hosts).
The primary issue was in tlsHandshakeWithTimeout in ztls/ztls.go. The select statement had:
select {
case <-ctx.Done():
return error
case errChan <- tlsConn.Handshake(): // BLOCKING CALL!
}
This pattern is fundamentally broken because tlsConn.Handshake() is evaluated before the select can choose a case. If the handshake blocks forever (unresponsive server), the context timeout can never fire.
Additional issues:
context.Background() with no timeoutdefer cancel() inside loops leaked contextsHandshake() in a goroutine so select can properly monitor both the handshake completion AND context timeoutpool.Acquire() callscancel() immediately instead of defer in loopsHandshakeContext() for proper timeout handling (standard library support)pool.Acquire() callspkg/tlsx/ztls/timeout_test.go with tests verifying timeout behavior=== RUN TestHandshakeTimeout
timeout_test.go:85: handshake correctly timed out after 2.001193s
--- PASS: TestHandshakeTimeout (2.00s)
/claim #819
Bug Fixes
Tests
Simplereally
@Simplereally
youssefosama3820009-commits
@youssefosama3820009-commits
ProjectDiscovery
@projectdiscovery