HTTP load generator, ApacheBench (ab) replacement
Go
Optionally allow insecure certificates.
Burcu Dogan2a112e190719
diff --git a/commands/boom.go b/commands/boom.goindex f9ea4bf..f7bd2c3 100644--- a/commands/boom.go+++ b/commands/boom.go@@ -28,10 +28,11 @@ type result struct {}type Boom struct {- Req *http.Request- N int- C int- Client *http.Client+ Req *http.Request+ N int+ C int+ Client *http.Client+ AllowInsecure boolstart time.Timeend time.Timediff --git a/commands/run.go b/commands/run.goindex 8a3c5f0..bd551fb 100644--- a/commands/run.go+++ b/commands/run.go@@ -15,6 +15,7 @@package commandsimport (+ "crypto/tls""io""io/ioutil""net/http"@@ -35,7 +36,10 @@ func (b *Boom) Run() {func (b *Boom) init() {if b.Client == nil {- b.Client = &http.Client{}+ tr := &http.Transport{+ TLSClientConfig: &tls.Config{InsecureSkipVerify: b.AllowInsecure},+ }+ b.Client = &http.Client{Transport: tr}}b.results = make(chan *result, b.N)b.bar = pb.StartNew(b.N)diff --git a/main.go b/main.goindex d6548bb..8dfa0f3 100644--- a/main.go+++ b/main.go@@ -26,11 +26,12 @@ import ()var (- flagMethod = flag.String("m", "GET", "")- flagHeaders = flag.String("h", "", "")- flagD = flag.String("d", "", "")- flagType = flag.String("t", "text/html", "")- flagAuth = flag.String("a", "", "")+ flagMethod = flag.String("m", "GET", "")+ flagHeaders = flag.String("h", "", "")+ flagD = flag.String("d", "", "")+ flagType = flag.String("t", "text/html", "")+ flagAuth = flag.String("a", "", "")+ flagInsecure = flag.Bool("allow-insecure", false, "")flagC = flag.Int("c", 50, "")flagN = flag.Int("n", 200, "")@@ -48,6 +49,9 @@ Options:-d HTTP request body.-t Content-type, defaults to "text/html".-a Basic authentication, username:password.++ -allow-insecure Allow bad/expired TLS/SSL certificates.+`func main() {@@ -63,7 +67,7 @@ func main() {n := *flagNc := *flagC- if n <= 0 || c <= 0 {+ if n <= 0 || c <= 0 {usageAndExit()}@@ -103,7 +107,7 @@ func main() {req.SetBasicAuth(matches[0][1], matches[0][2])}- (&commands.Boom{N: n, C: c, Req: req}).Run()+ (&commands.Boom{N: n, C: c, Req: req, AllowInsecure: *flagInsecure}).Run()}func usageAndExit() {