Merge pull request #381 from projectdiscovery/bugfix-global-dealer

fixing global dealer
dev
Mzack9999 2020-10-24 01:31:18 +02:00 committed by GitHub
commit bb4774623e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View File

@ -72,6 +72,7 @@ func (r *Runner) processTemplateWithList(p progress.IProgress, template *templat
Decolorizer: r.decolorizer, Decolorizer: r.decolorizer,
StopAtFirstMatch: r.options.StopAtFirstMatch, StopAtFirstMatch: r.options.StopAtFirstMatch,
PF: r.pf, PF: r.pf,
Dialer: &r.dialer,
}) })
} }

View File

@ -12,6 +12,7 @@ import (
"github.com/logrusorgru/aurora" "github.com/logrusorgru/aurora"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/projectdiscovery/gologger" "github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/httpx/common/cache"
"github.com/projectdiscovery/nuclei/v2/internal/bufwriter" "github.com/projectdiscovery/nuclei/v2/internal/bufwriter"
"github.com/projectdiscovery/nuclei/v2/internal/progress" "github.com/projectdiscovery/nuclei/v2/internal/progress"
"github.com/projectdiscovery/nuclei/v2/internal/tracelog" "github.com/projectdiscovery/nuclei/v2/internal/tracelog"
@ -48,6 +49,9 @@ type Runner struct {
// output coloring // output coloring
colorizer colorizer.NucleiColorizer colorizer colorizer.NucleiColorizer
decolorizer *regexp.Regexp decolorizer *regexp.Regexp
// http dialer
dialer cache.DialerFunc
} }
// New creates a new client for running enumeration process. // New creates a new client for running enumeration process.
@ -194,6 +198,12 @@ func New(options *Options) (*Runner, error) {
collaborator.DefaultCollaborator.Collab.AddBIID(options.BurpCollaboratorBiid) collaborator.DefaultCollaborator.Collab.AddBIID(options.BurpCollaboratorBiid)
} }
// Create Dialer
runner.dialer, err = cache.NewDialer(cache.DefaultOptions)
if err != nil {
return nil, err
}
return runner, nil return runner, nil
} }

View File

@ -89,14 +89,16 @@ type HTTPOptions struct {
ColoredOutput bool ColoredOutput bool
StopAtFirstMatch bool StopAtFirstMatch bool
PF *projetctfile.ProjectFile PF *projetctfile.ProjectFile
Dialer *cache.DialerFunc
} }
// NewHTTPExecuter creates a new HTTP executer from a template // NewHTTPExecuter creates a new HTTP executer from a template
// and a HTTP request query. // and a HTTP request query.
func NewHTTPExecuter(options *HTTPOptions) (*HTTPExecuter, error) { func NewHTTPExecuter(options *HTTPOptions) (*HTTPExecuter, error) {
var proxyURL *url.URL var (
proxyURL *url.URL
var err error err error
)
if options.ProxyURL != "" { if options.ProxyURL != "" {
proxyURL, err = url.Parse(options.ProxyURL) proxyURL, err = url.Parse(options.ProxyURL)
@ -601,13 +603,8 @@ func makeHTTPClient(proxyURL *url.URL, options *HTTPOptions) (*retryablehttp.Cli
followRedirects := options.BulkHTTPRequest.Redirects followRedirects := options.BulkHTTPRequest.Redirects
maxRedirects := options.BulkHTTPRequest.MaxRedirects maxRedirects := options.BulkHTTPRequest.MaxRedirects
dialer, err := cache.NewDialer(cache.DefaultOptions)
if err != nil {
return nil, err
}
transport := &http.Transport{ transport := &http.Transport{
DialContext: dialer, DialContext: *options.Dialer,
MaxIdleConns: maxIdleConns, MaxIdleConns: maxIdleConns,
MaxIdleConnsPerHost: maxIdleConnsPerHost, MaxIdleConnsPerHost: maxIdleConnsPerHost,
MaxConnsPerHost: maxConnsPerHost, MaxConnsPerHost: maxConnsPerHost,