diff --git a/go.mod b/go.mod index 98c107d0..26dbab93 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/onsi/gomega v1.34.0 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model v0.6.1 - github.com/tsenart/vegeta/v12 v12.11.1 + github.com/tsenart/vegeta/v12 v12.11.3 ) require ( diff --git a/go.sum b/go.sum index 642b572a..f206dc39 100644 --- a/go.sum +++ b/go.sum @@ -62,11 +62,11 @@ github.com/streadway/quantile v0.0.0-20220407130108-4246515d968d h1:X4+kt6zM/OVO github.com/streadway/quantile v0.0.0-20220407130108-4246515d968d/go.mod h1:lbP8tGiBjZ5YWIc2fzuRpTaz0b/53vT6PEs3QuAWzuU= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tsenart/vegeta/v12 v12.11.1 h1:Rbwe7Zxr7sJ+BDTReemeQalYPvKiSV+O7nwmUs20B3E= -github.com/tsenart/vegeta/v12 v12.11.1/go.mod h1:swiFmrgpqj2llHURgHYFRFN0tfrIrlnspg01HjwOnSQ= +github.com/tsenart/vegeta/v12 v12.11.3 h1:U0rW+Vt/WrG2566n6YXcijvP41EoKzL8/85Xnx+f/wQ= +github.com/tsenart/vegeta/v12 v12.11.3/go.mod h1:gpdfR++WHV9/RZh4oux0f6lNPhsOH8pCjIGUlcPQe1M= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/vendor/github.com/tsenart/vegeta/v12/lib/attack.go b/vendor/github.com/tsenart/vegeta/v12/lib/attack.go index 80df5e1a..0e43e91f 100644 --- a/vendor/github.com/tsenart/vegeta/v12/lib/attack.go +++ b/vendor/github.com/tsenart/vegeta/v12/lib/attack.go @@ -329,20 +329,7 @@ func DNSCaching(ttl time.Duration) func(*Attacker) { rng.Shuffle(len(ips), func(i, j int) { ips[i], ips[j] = ips[j], ips[i] }) - // In place filtering of ips to only include the first IPv4 and IPv6. - j := 0 - for i := 0; i < len(ips) && j < 2; i++ { - ip := net.ParseIP(ips[i]) - switch { - case len(ip) == net.IPv4len && (j == 0 || len(ips[j-1]) == net.IPv6len): - fallthrough - case len(ip) == net.IPv6len && (j == 0 || len(ips[j-1]) == net.IPv4len): - ips[j] = ips[i] - j++ - } - } - - ips = ips[:j] + ips = firstOfEachIPFamily(ips) type result struct { conn net.Conn @@ -375,6 +362,33 @@ func DNSCaching(ttl time.Duration) func(*Attacker) { } } +// firstOfEachIPFamily returns the first IP of each IP family in the input slice. +func firstOfEachIPFamily(ips []string) []string { + if len(ips) == 0 { + return ips + } + + var ( + lastV4 bool + each = ips[:0] + ) + + for i := 0; i < len(ips) && len(each) < 2; i++ { + ip := net.ParseIP(ips[i]) + if ip == nil { + continue + } + + isV4 := ip.To4() != nil + if len(each) == 0 || isV4 != lastV4 { + each = append(each, ips[i]) + lastV4 = isV4 + } + } + + return each +} + type attack struct { name string began time.Time diff --git a/vendor/modules.txt b/vendor/modules.txt index fe3c4d6c..79b3c6e0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -114,8 +114,8 @@ github.com/prometheus/procfs/internal/util # github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 ## explicit; go 1.12 github.com/rs/dnscache -# github.com/tsenart/vegeta/v12 v12.11.1 -## explicit; go 1.20 +# github.com/tsenart/vegeta/v12 v12.11.3 +## explicit; go 1.22 github.com/tsenart/vegeta/v12/lib # golang.org/x/net v0.27.0 ## explicit; go 1.18