Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/whois/rdapclientpool/clientpool.go
2073 views
1
package rdapclientpool
2
3
import (
4
"sync"
5
6
"github.com/projectdiscovery/gologger"
7
"github.com/projectdiscovery/nuclei/v3/pkg/types"
8
"github.com/projectdiscovery/rdap"
9
)
10
11
var normalClient *rdap.Client
12
var m sync.Mutex
13
14
// Init initializes the client pool implementation
15
func Init(options *types.Options) error {
16
m.Lock()
17
defer m.Unlock()
18
19
// Don't create clients if already created in the past.
20
if normalClient != nil {
21
return nil
22
}
23
24
normalClient = &rdap.Client{}
25
if options.Verbose || options.Debug || options.DebugRequests || options.DebugResponse {
26
normalClient.Verbose = func(text string) {
27
gologger.Debug().Msgf("rdap: %s", text)
28
}
29
}
30
return nil
31
}
32
33
func getNormalClient() *rdap.Client {
34
m.Lock()
35
defer m.Unlock()
36
return normalClient
37
}
38
39
// Configuration contains the custom configuration options for a client - placeholder
40
type Configuration struct{}
41
42
// Hash returns the hash of the configuration to allow client pooling - placeholder
43
func (c *Configuration) Hash() string {
44
return ""
45
}
46
47
// Get creates or gets a client for the protocol based on custom configuration
48
func Get(options *types.Options, configuration *Configuration) (*rdap.Client, error) {
49
return getNormalClient(), nil
50
}
51
52