mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-25 09:25:29 +00:00
* Use proxy for dns and ssl templates - while using template execute level function we need to override custom dialer * rename overridedialer to customdialer * Add proxy into hash - proxy client is shared between non proxy requests * add dialer into request object - use request.dialer instead of global variable * resolve comments * rename dialer
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package networkclientpool
|
|
|
|
import (
|
|
"github.com/projectdiscovery/fastdialer/fastdialer"
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
|
)
|
|
|
|
var (
|
|
normalClient *fastdialer.Dialer
|
|
)
|
|
|
|
// Init initializes the clientpool implementation
|
|
func Init(options *types.Options) error {
|
|
// Don't create clients if already created in the past.
|
|
if normalClient != nil {
|
|
return nil
|
|
}
|
|
normalClient = protocolstate.Dialer
|
|
return nil
|
|
}
|
|
|
|
// Configuration contains the custom configuration options for a client
|
|
type Configuration struct {
|
|
CustomDialer *fastdialer.Dialer
|
|
}
|
|
|
|
// Hash returns the hash of the configuration to allow client pooling
|
|
func (c *Configuration) Hash() string {
|
|
return ""
|
|
}
|
|
|
|
// Get creates or gets a client for the protocol based on custom configuration
|
|
func Get(options *types.Options, configuration *Configuration /*TODO review unused parameters*/) (*fastdialer.Dialer, error) {
|
|
|
|
if configuration != nil && configuration.CustomDialer != nil {
|
|
return configuration.CustomDialer, nil
|
|
}
|
|
|
|
return normalClient, nil
|
|
}
|