fix -silent switch still show banner (#524)

* fix readme golang demo for v2.5.0

* fix -silent switch still show banner

* small refactor

Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
Co-authored-by: zhangchengguo <zhangchengguo@360.cn>
Co-authored-by: Ignacio Feijoo <ifeijoo@infobytesec.com>
Co-authored-by: mzack <marco.rivoli.nvh@gmail.com>
dev
Ignacio Feijoo 2022-03-30 04:26:35 -03:00 committed by GitHub
parent 029292e2f6
commit 5b6342c0c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 15 deletions

View File

@ -242,23 +242,16 @@ import (
)
func main() {
config := runner.ConfigFile{
// Use the default list of resolvers by marshaling it to the config
Resolvers: resolve.DefaultResolvers,
// Use the default list of passive sources
Sources: passive.DefaultSources,
// Use the default list of all passive sources
AllSources: passive.DefaultAllSources,
// Use the default list of recursive sources
Recursive: passive.DefaultRecursiveSources,
}
runnerInstance, err := 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
YAMLConfig: config,
})
Resolvers: resolve.DefaultResolvers, // Use the default list of resolvers by marshaling it to the config
Sources: passive.DefaultSources, // Use the default list of passive sources
AllSources: passive.DefaultAllSources, // Use the default list of all passive sources
Recursive: passive.DefaultRecursiveSources, // Use the default list of recursive sources
Providers: &runner.Providers{}, // Use empty api keys for all providers
})
buf := bytes.Buffer{}
err = runnerInstance.EnumerateSingleDomain(context.Background(), "projectdiscovery.io", []io.Writer{&buf})

View File

@ -66,8 +66,6 @@ type Options struct {
// ParseOptions parses the command line flags provided by a user
func ParseOptions() *Options {
showBanner()
// Migrate config to provider config
if fileutil.FileExists(defaultConfigLocation) && !fileutil.FileExists(defaultProviderConfigLocation) {
gologger.Info().Msgf("Detected old %s config file, trying to migrate providers to %s\n", defaultConfigLocation, defaultProviderConfigLocation)
@ -81,6 +79,7 @@ func ParseOptions() *Options {
}
options := &Options{}
var err error
flagSet := goflags.NewFlagSet()
flagSet.SetDescription(`Subfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.`)
@ -174,6 +173,10 @@ func ParseOptions() *Options {
options.preProcessOptions()
if !options.Silent {
showBanner()
}
// Validate the options passed by the user and if any
// invalid options have been used, exit.
err = options.validateOptions()