Skip to content

Commit ce93cd8

Browse files
committed
lib: use fixed IP selection function
Last release introduced a fixed firstOfEachIPFamily function, but didn't integrate it.
1 parent 1799abc commit ce93cd8

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/attack.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,20 +329,7 @@ func DNSCaching(ttl time.Duration) func(*Attacker) {
329329

330330
rng.Shuffle(len(ips), func(i, j int) { ips[i], ips[j] = ips[j], ips[i] })
331331

332-
// In place filtering of ips to only include the first IPv4 and IPv6.
333-
j := 0
334-
for i := 0; i < len(ips) && j < 2; i++ {
335-
ip := net.ParseIP(ips[i])
336-
switch {
337-
case len(ip) == net.IPv4len && (j == 0 || len(ips[j-1]) == net.IPv6len):
338-
fallthrough
339-
case len(ip) == net.IPv6len && (j == 0 || len(ips[j-1]) == net.IPv4len):
340-
ips[j] = ips[i]
341-
j++
342-
}
343-
}
344-
345-
ips = ips[:j]
332+
ips = firstOfEachIPFamily(ips)
346333

347334
type result struct {
348335
conn net.Conn

0 commit comments

Comments
 (0)