diff --git a/go.mod b/go.mod index 0831168d23..598c411f29 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/openzipkin/zipkin-go v0.4.3 github.com/spf13/pflag v1.0.5 - github.com/tsenart/vegeta/v12 v12.11.3 + github.com/tsenart/vegeta/v12 v12.12.0 go.opencensus.io v0.24.0 go.uber.org/automaxprocs v1.5.3 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index 04103072cf..7fa6f700dd 100644 --- a/go.sum +++ b/go.sum @@ -341,8 +341,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o 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/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= -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= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/vendor/github.com/tsenart/vegeta/v12/lib/attack.go b/vendor/github.com/tsenart/vegeta/v12/lib/attack.go index 0e43e91fee..d2f1cf5a41 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 b93ad7257d..d577a7d4e9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -182,7 +182,7 @@ github.com/rs/dnscache # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# 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 # go.opencensus.io v0.24.0