Skip to content

Commit

Permalink
removed New()
Browse files Browse the repository at this point in the history
replaced New() with agents = append(agents, &{PPROVIDER-NAME}.Agent{})
  • Loading branch information
xm1k3 committed Mar 1, 2023
1 parent 6570ce6 commit f0e0922
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 55 deletions.
25 changes: 11 additions & 14 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/projectdiscovery/uncover/uncover/agent/fofa"
"github.com/projectdiscovery/uncover/uncover/agent/hunter"
"github.com/projectdiscovery/uncover/uncover/agent/netlas"
"github.com/projectdiscovery/uncover/uncover/agent/publicwww"
"github.com/projectdiscovery/uncover/uncover/agent/quake"
"github.com/projectdiscovery/uncover/uncover/agent/shodan"
"github.com/projectdiscovery/uncover/uncover/agent/shodanidb"
Expand Down Expand Up @@ -94,37 +93,35 @@ func (r *Runner) Run(ctx context.Context, query ...string) error {
// declare clients
for _, engine := range r.options.Engine {
var (
agent uncover.Agent
err error
err error
)
switch engine {
case "shodan":
agent, err = shodan.New()
agents = append(agents, &shodan.Agent{})
case "censys":
agent, err = censys.New()
agents = append(agents, &censys.Agent{})
case "fofa":
agent, err = fofa.New()
agents = append(agents, &fofa.Agent{})
case "shodan-idb":
agent, err = shodanidb.New()
agents = append(agents, &shodanidb.Agent{})
case "quake":
agent, err = quake.New()
agents = append(agents, &quake.Agent{})
case "hunter":
agent, err = hunter.New()
agents = append(agents, &hunter.Agent{})
case "zoomeye":
agent, err = zoomeye.New()
agents = append(agents, &zoomeye.Agent{})
case "netlas":
agent, err = netlas.New()
agents = append(agents, &netlas.Agent{})
case "criminalip":
agent, err = criminalip.New()
agents = append(agents, &criminalip.Agent{})
case "publicwww":
agent, err = publicwww.New()
agents = append(agents, &criminalip.Agent{})
default:
err = errors.New("unknown agent type")
}
if err != nil {
return err
}
agents = append(agents, agent)
}

// open the output file - always overwrite
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/censys/censys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "censys"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/criminalip/criminalip.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "criminalip"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/fofa/fofa.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "fofa"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/hunter/hunter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "hunter"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/netlas/netlas.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "netlas"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/publicwww/publicwww.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "publicwww"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/quake/quake.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "quake"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/shodan/shodan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "shodan"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/shodanidb/shodan.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "shodan-idb"
}
Expand Down
4 changes: 0 additions & 4 deletions uncover/agent/zoomeye/zoomeye.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const (

type Agent struct{}

func New() (uncover.Agent, error) {
return &Agent{}, nil
}

func (agent *Agent) Name() string {
return "zoomeye"
}
Expand Down
8 changes: 7 additions & 1 deletion uncover/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ func NewSession(keys *Keys, retryMax, timeout, delay int, engines []string) (*Se
return session, nil
}

func (s *Session) Do(request *retryablehttp.Request) (*http.Response, error) {
func (s *Session) Do(request *retryablehttp.Request, sources ...string) (*http.Response, error) {
for _, source := range sources {
err := s.RateLimits.Take(source)
if err != nil {
return nil, err
}
}
// close request connection (does not reuse connections)
request.Close = true
resp, err := s.Client.Do(request)
Expand Down

0 comments on commit f0e0922

Please sign in to comment.