diff --git a/go.mod b/go.mod index b2d5cceb..5e654370 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/onsi/gomega v1.34.1 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model v0.6.1 - github.com/tsenart/vegeta/v12 v12.11.3 + github.com/tsenart/vegeta/v12 v12.12.0 ) require ( diff --git a/go.sum b/go.sum index 00b2bbd4..ac96e2a9 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ 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.3 h1:U0rW+Vt/WrG2566n6YXcijvP41EoKzL8/85Xnx+f/wQ= -github.com/tsenart/vegeta/v12 v12.11.3/go.mod h1:gpdfR++WHV9/RZh4oux0f6lNPhsOH8pCjIGUlcPQe1M= +github.com/tsenart/vegeta/v12 v12.12.0 h1:FKMMNomd3auAElO/TtbXzRFXAKGee6N/GKCGweFVm2U= +github.com/tsenart/vegeta/v12 v12.12.0/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-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= diff --git a/vendor/github.com/tsenart/vegeta/v12/lib/attack.go b/vendor/github.com/tsenart/vegeta/v12/lib/attack.go index 0e43e91f..d2f1cf5a 100644 --- a/vendor/github.com/tsenart/vegeta/v12/lib/attack.go +++ b/vendor/github.com/tsenart/vegeta/v12/lib/attack.go @@ -28,6 +28,9 @@ type Attacker struct { maxWorkers uint64 maxBody int64 redirects int + seqmu sync.Mutex + seq uint64 + began time.Time chunked bool } @@ -272,6 +275,45 @@ func ProxyHeader(h http.Header) func(*Attacker) { } } +// ConnectTo returns a functional option which makes the attacker use the +// passed in map to translate target addr:port pairs. When used with DNSCaching, +// it must be used after it. +func ConnectTo(addrMap map[string][]string) func(*Attacker) { + return func(a *Attacker) { + if len(addrMap) == 0 { + return + } + + tr, ok := a.client.Transport.(*http.Transport) + if !ok { + return + } + + dial := tr.DialContext + if dial == nil { + dial = a.dialer.DialContext + } + + type roundRobin struct { + addrs []string + n int + } + + connectTo := make(map[string]*roundRobin, len(addrMap)) + for k, v := range addrMap { + connectTo[k] = &roundRobin{addrs: v} + } + + tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { + if cm, ok := connectTo[addr]; ok { + cm.n = (cm.n + 1) % len(cm.addrs) + addr = cm.addrs[cm.n] + } + return dial(ctx, network, addr) + } + } +} + // DNSCaching returns a functional option that enables DNS caching for // the given ttl. When ttl is zero cached entries will never expire. // When ttl is non-zero, this will start a refresh go-routine that updates diff --git a/vendor/modules.txt b/vendor/modules.txt index 33ebf62b..9ba38c31 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -114,7 +114,7 @@ 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.3 +# github.com/tsenart/vegeta/v12 v12.12.0 ## explicit; go 1.22 github.com/tsenart/vegeta/v12/lib # golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56