diff --git a/output_http.go b/output_http.go index de59d7f..0b47799 100644 --- a/output_http.go +++ b/output_http.go @@ -21,8 +21,9 @@ type response struct { type HTTPOutputConfig struct { redirectLimit int - stats bool - workers int + stats bool + workers int + queueLen int elasticSearch string @@ -71,8 +72,8 @@ func NewHTTPOutput(address string, config *HTTPOutputConfig) io.Writer { o.queueStats = NewGorStat("output_http") } - o.queue = make(chan []byte, 1000) - o.responses = make(chan response, 1000) + o.queue = make(chan []byte, o.config.queueLen) + o.responses = make(chan response, o.config.queueLen) o.needWorker = make(chan int, 1) // Initial workers count diff --git a/settings.go b/settings.go index 2591a92..58831b2 100644 --- a/settings.go +++ b/settings.go @@ -150,6 +150,7 @@ func init() { flag.Var(&Settings.outputHTTP, "output-http", "Forwards incoming requests to given http address.\n\t# Redirect all incoming requests to staging.com address \n\tgor --input-raw :80 --output-http http://staging.com") flag.IntVar(&Settings.outputHTTPConfig.BufferSize, "output-http-response-buffer", 0, "HTTP response buffer size, all data after this size will be discarded.") flag.IntVar(&Settings.outputHTTPConfig.workers, "output-http-workers", 0, "Gor uses dynamic worker scaling by default. Enter a number to run a set number of workers.") + flag.IntVar(&Settings.outputHTTPConfig.queueLen, "output-http-queue-len", 1000, "Number of requests that can be queued for output, if all workers are busy. default = 1000") flag.IntVar(&Settings.outputHTTPConfig.redirectLimit, "output-http-redirects", 0, "Enable how often redirects should be followed.") flag.DurationVar(&Settings.outputHTTPConfig.Timeout, "output-http-timeout", 5*time.Second, "Specify HTTP request/response timeout. By default 5s. Example: --output-http-timeout 30s") flag.BoolVar(&Settings.outputHTTPConfig.TrackResponses, "output-http-track-response", false, "If turned on, HTTP output responses will be set to all outputs like stdout, file and etc.")