This PR fixes issue #819 where tlsx hangs indefinitely after processing ~25k targets during long-running scans.
The bufio.Writer buffer in fileWriter was not being flushed during long-running scans. When multiple goroutines attempt concurrent writes:
The issue is exacerbated by:
-cipher-concurrency 10)Flush the buffer after each write to prevent accumulation:
err = w.writer.Flush()
if err != nil {
return err
}
Sync to disk after each write to prevent data loss:
w.file.Sync()
Add mutex to prevent race conditions in concurrent writes:
w.mu.Lock()
defer w.mu.Unlock()
pkg/output/file_writer.gosync.Mutex to fileWriter structWrite() to flush and sync after each writeClose() to acquire lock before flushingpkg/output/file_writer_test.goTestFileWriterConcurrent: Tests concurrent writes from 10 goroutinesTestFileWriterFlush: Verifies flush behaviortlsx -list 30k-hosts.txt -json -output results.jsonl
# Hangs after ~25k targets, output truncated mid-JSON
tlsx -list 30k-hosts.txt -json -output results.jsonl
# Completes successfully, all 30k lines written
go test -v ./pkg/output -run TestFileWriterConcurrent
# PASS: 1000 concurrent writes complete without deadlock
Fixes: #819
/claim #819
Bug Fixes
Tests
EthanHan
@EthanHan
youssefosama3820009-commits
@youssefosama3820009-commits
ProjectDiscovery
@projectdiscovery