2022-11-08 12:57:18 +01:00
|
|
|
package rdapclientpool
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-09 14:47:26 -05:00
|
|
|
"sync"
|
|
|
|
|
|
2022-11-08 12:57:18 +01:00
|
|
|
"github.com/projectdiscovery/gologger"
|
2023-10-17 17:44:13 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
2022-11-08 12:57:18 +01:00
|
|
|
"github.com/projectdiscovery/rdap"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var normalClient *rdap.Client
|
2025-07-09 14:47:26 -05:00
|
|
|
var m sync.Mutex
|
2022-11-08 12:57:18 +01:00
|
|
|
|
|
|
|
|
// Init initializes the client pool implementation
|
|
|
|
|
func Init(options *types.Options) error {
|
2025-07-09 14:47:26 -05:00
|
|
|
m.Lock()
|
|
|
|
|
defer m.Unlock()
|
|
|
|
|
|
2022-11-08 12:57:18 +01:00
|
|
|
// Don't create clients if already created in the past.
|
|
|
|
|
if normalClient != nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
normalClient = &rdap.Client{}
|
|
|
|
|
if options.Verbose || options.Debug || options.DebugRequests || options.DebugResponse {
|
|
|
|
|
normalClient.Verbose = func(text string) {
|
|
|
|
|
gologger.Debug().Msgf("rdap: %s", text)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-18 13:40:58 -05:00
|
|
|
func getNormalClient() *rdap.Client {
|
|
|
|
|
m.Lock()
|
|
|
|
|
defer m.Unlock()
|
|
|
|
|
return normalClient
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-08 12:57:18 +01:00
|
|
|
// Configuration contains the custom configuration options for a client - placeholder
|
|
|
|
|
type Configuration struct{}
|
|
|
|
|
|
|
|
|
|
// Hash returns the hash of the configuration to allow client pooling - placeholder
|
|
|
|
|
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) (*rdap.Client, error) {
|
2025-07-18 13:40:58 -05:00
|
|
|
return getNormalClient(), nil
|
2022-11-08 12:57:18 +01:00
|
|
|
}
|