mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-23 14:25:24 +00:00
fix race condition
This commit is contained in:
parent
4d5eb9c484
commit
3064788d35
@ -32,6 +32,7 @@ var (
|
|||||||
forceMaxRedirects int
|
forceMaxRedirects int
|
||||||
normalClient *retryablehttp.Client
|
normalClient *retryablehttp.Client
|
||||||
clientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
|
clientPool *mapsutil.SyncLockMap[string, *retryablehttp.Client]
|
||||||
|
rawHttpClientMu sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init initializes the clientpool implementation
|
// Init initializes the clientpool implementation
|
||||||
@ -102,6 +103,22 @@ type Configuration struct {
|
|||||||
ResponseHeaderTimeout time.Duration
|
ResponseHeaderTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) Clone() *Configuration {
|
||||||
|
clone := *c
|
||||||
|
if c.Connection != nil {
|
||||||
|
cloneConnection := &ConnectionConfiguration{
|
||||||
|
DisableKeepAlive: c.Connection.DisableKeepAlive,
|
||||||
|
}
|
||||||
|
if c.Connection.HasCookieJar() {
|
||||||
|
cookiejar := *c.Connection.GetCookieJar()
|
||||||
|
cloneConnection.SetCookieJar(&cookiejar)
|
||||||
|
}
|
||||||
|
clone.Connection = cloneConnection
|
||||||
|
}
|
||||||
|
|
||||||
|
return &clone
|
||||||
|
}
|
||||||
|
|
||||||
// Hash returns the hash of the configuration to allow client pooling
|
// Hash returns the hash of the configuration to allow client pooling
|
||||||
func (c *Configuration) Hash() string {
|
func (c *Configuration) Hash() string {
|
||||||
builder := &strings.Builder{}
|
builder := &strings.Builder{}
|
||||||
@ -131,6 +148,9 @@ func (c *Configuration) HasStandardOptions() bool {
|
|||||||
|
|
||||||
// GetRawHTTP returns the rawhttp request client
|
// GetRawHTTP returns the rawhttp request client
|
||||||
func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
func GetRawHTTP(options *protocols.ExecutorOptions) *rawhttp.Client {
|
||||||
|
rawHttpClientMu.Lock()
|
||||||
|
defer rawHttpClientMu.Unlock()
|
||||||
|
|
||||||
if rawHttpClient == nil {
|
if rawHttpClient == nil {
|
||||||
rawHttpOptions := rawhttp.DefaultOptions
|
rawHttpOptions := rawhttp.DefaultOptions
|
||||||
if types.ProxyURL != "" {
|
if types.ProxyURL != "" {
|
||||||
|
|||||||
@ -770,7 +770,7 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ
|
|||||||
|
|
||||||
// check for cookie related configuration
|
// check for cookie related configuration
|
||||||
if input.CookieJar != nil {
|
if input.CookieJar != nil {
|
||||||
connConfiguration := request.connConfiguration
|
connConfiguration := request.connConfiguration.Clone()
|
||||||
connConfiguration.Connection.SetCookieJar(input.CookieJar)
|
connConfiguration.Connection.SetCookieJar(input.CookieJar)
|
||||||
modifiedConfig = connConfiguration
|
modifiedConfig = connConfiguration
|
||||||
}
|
}
|
||||||
@ -778,7 +778,8 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ
|
|||||||
updatedTimeout, ok := generatedRequest.request.Context().Value(httpclientpool.WithCustomTimeout{}).(httpclientpool.WithCustomTimeout)
|
updatedTimeout, ok := generatedRequest.request.Context().Value(httpclientpool.WithCustomTimeout{}).(httpclientpool.WithCustomTimeout)
|
||||||
if ok {
|
if ok {
|
||||||
if modifiedConfig == nil {
|
if modifiedConfig == nil {
|
||||||
modifiedConfig = request.connConfiguration
|
connConfiguration := request.connConfiguration.Clone()
|
||||||
|
modifiedConfig = connConfiguration
|
||||||
}
|
}
|
||||||
modifiedConfig.ResponseHeaderTimeout = updatedTimeout.Timeout
|
modifiedConfig.ResponseHeaderTimeout = updatedTimeout.Timeout
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user