Skip to content

Commit e49c367

Browse files
committed
attack: early cancel ctx only when there's no err
This fixes a bug introduced in 074c530 where we'd be cancelling the racing go-routines even when the first one produced an error, hence returning an error. Signed-off-by: Tomás Senart <[email protected]>
1 parent 3fd94ee commit e49c367

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/attack.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ func DNSCaching(ttl time.Duration) func(*Attacker) {
356356
for _, ip := range ips {
357357
go func(ip string) {
358358
conn, err := dial(ctx, network, net.JoinHostPort(ip, port))
359-
cancel()
359+
if err == nil {
360+
cancel()
361+
}
360362
ch <- result{conn, err}
361363
}(ip)
362364
}

0 commit comments

Comments
 (0)