From c10cfb2213b58c33431ce8257de5d850681f6146 Mon Sep 17 00:00:00 2001 From: nakabonne Date: Thu, 8 Oct 2020 22:17:08 +0900 Subject: [PATCH] Remove dependency on vegeta from default --- attacker/attacker.go | 4 +++- main.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/attacker/attacker.go b/attacker/attacker.go index c11e1d0..0e593ea 100644 --- a/attacker/attacker.go +++ b/attacker/attacker.go @@ -21,6 +21,8 @@ const ( DefaultConnections = 10000 ) +var DefaultLocalAddr = net.IPAddr{IP: net.IPv4zero} + type Attacker interface { Attack(vegeta.Targeter, vegeta.Pacer, time.Duration, string) <-chan *vegeta.Result Stop() @@ -75,7 +77,7 @@ func Attack(ctx context.Context, target string, resCh chan *Result, metricsCh ch opts.Connections = DefaultConnections } if opts.LocalAddr.IP == nil { - opts.LocalAddr = vegeta.DefaultLocalAddr + opts.LocalAddr = DefaultLocalAddr } if opts.Attacker == nil { opts.Attacker = vegeta.NewAttacker( diff --git a/main.go b/main.go index f0002a5..208b3f4 100644 --- a/main.go +++ b/main.go @@ -79,8 +79,8 @@ func parseFlags(stdout, stderr io.Writer) (*cli, error) { flagSet.Uint64VarP(&c.workers, "workers", "w", attacker.DefaultWorkers, "Amount of initial workers to spawn.") flagSet.Uint64VarP(&c.maxWorkers, "max-workers", "W", attacker.DefaultMaxWorkers, "Amount of maximum workers to spawn.") flagSet.IntVarP(&c.connections, "connections", "c", attacker.DefaultConnections, "Amount of maximum open idle connections per target host") - flagSet.BoolVar(&c.http2, "http2", true, "Issue HTTP/2 requests to servers which support it. (default true)") - flagSet.StringVarP(&c.localAddress, "local-address", "L", "0.0.0.0", "Local IP address.") + flagSet.BoolVar(&c.http2, "http2", true, "Issue HTTP/2 requests to servers which support it.") + flagSet.StringVar(&c.localAddress, "local-addr", "0.0.0.0", "Local IP address.") flagSet.Usage = c.usage if err := flagSet.Parse(os.Args[1:]); err != nil { if !errors.Is(err, flag.ErrHelp) {