2020-12-30 14:54:20 +05:30
|
|
|
package networkclientpool
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-09 14:47:26 -05:00
|
|
|
"fmt"
|
|
|
|
|
|
2020-12-30 14:54:20 +05:30
|
|
|
"github.com/projectdiscovery/fastdialer/fastdialer"
|
2023-10-17 17:44:13 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
2020-12-30 14:54:20 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Init initializes the clientpool implementation
|
2024-04-03 17:50:57 +02:00
|
|
|
func Init(options *types.Options) error {
|
2020-12-30 14:54:20 +05:30
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Configuration contains the custom configuration options for a client
|
2025-06-16 22:24:52 +05:30
|
|
|
type Configuration struct {
|
|
|
|
|
CustomDialer *fastdialer.Dialer
|
|
|
|
|
}
|
2020-12-30 14:54:20 +05:30
|
|
|
|
|
|
|
|
// 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
|
2021-08-23 16:21:18 +03:00
|
|
|
func Get(options *types.Options, configuration *Configuration /*TODO review unused parameters*/) (*fastdialer.Dialer, error) {
|
2025-06-16 22:24:52 +05:30
|
|
|
if configuration != nil && configuration.CustomDialer != nil {
|
|
|
|
|
return configuration.CustomDialer, nil
|
|
|
|
|
}
|
2025-07-09 14:47:26 -05:00
|
|
|
dialers := protocolstate.GetDialersWithId(options.ExecutionId)
|
|
|
|
|
if dialers == nil {
|
|
|
|
|
return nil, fmt.Errorf("dialers not initialized for %s", options.ExecutionId)
|
|
|
|
|
}
|
|
|
|
|
return dialers.Fastdialer, nil
|
2020-12-30 14:54:20 +05:30
|
|
|
}
|