这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ShubhamRasal
Copy link
Contributor

@ShubhamRasal ShubhamRasal commented Nov 9, 2022

package main

import (
	"bytes"
	"fmt"
	"io"
	"log"

	"github.com/projectdiscovery/subfinder/v2/pkg/resolve"
	"github.com/projectdiscovery/subfinder/v2/pkg/runner"
)

func main() {
	mycallback := func(s *resolve.HostEntry) {
		fmt.Println("Processing:", s.Host, " Source:", s.Source)
	}
	runnerInstance, _ := runner.NewRunner(&runner.Options{
		Threads:            10,                       // Thread controls the number of threads to use for active enumerations
		Timeout:            30,                       // Timeout is the seconds to wait for sources to respond
		MaxEnumerationTime: 10,                       // MaxEnumerationTime is the maximum amount of time in mins to wait for enumeration
		Resolvers:          resolve.DefaultResolvers, // Use the default list of resolvers by marshaling it to the config
		OnResult:           mycallback,
	})

	buf := bytes.Buffer{}
	err := runnerInstance.EnumerateSingleDomain("projectdiscovery.io", []io.Writer{&buf})
	if err != nil {
		log.Fatal(err)
	}

	data, err := io.ReadAll(&buf)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s", data)
}

@ShubhamRasal ShubhamRasal self-assigned this Nov 9, 2022
@ShubhamRasal ShubhamRasal added the Status: In Progress This issue is being worked on, and has someone assigned. label Nov 9, 2022
@ShubhamRasal ShubhamRasal linked an issue Nov 9, 2022 that may be closed by this pull request
@ShubhamRasal ShubhamRasal added Status: Review Needed The issue has a PR attached to it which needs to be reviewed and removed Status: In Progress This issue is being worked on, and has someone assigned. labels Nov 9, 2022
Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - Missing things:

  • Update docs (use as a library section)
  • Check if any integration test covering library usage needs to be updated

@ehsandeep ehsandeep merged commit 86e1d1a into dev Nov 11, 2022
@ehsandeep ehsandeep deleted the issue-593-add-callback branch November 11, 2022 18:40
@ehsandeep ehsandeep removed the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ResultCallback in runner.Options

4 participants