diff --git a/README.md b/README.md index 2d8752c2a..75c82afd0 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,8 @@ OUTPUT: -oI, -ip include host IP in output (-active only) CONFIGURATION: - -config string flag config file (default "$HOME/.config/subfinder/config.yaml") - -pc, -provider-config string provider config file (default "$HOME/.config/subfinder/provider-config.yaml") + -config string flag config file (default "$CONFIG/subfinder/config.yaml") + -pc, -provider-config string provider config file (default "$CONFIG/subfinder/provider-config.yaml") -r string[] comma separated list of resolvers to use -rL, -rlist string file containing list of resolvers to use -nW, -active display active subdomains only @@ -125,7 +125,7 @@ go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest You can also use the `subfinder -ls` command to display all the available sources. -These values are stored in the `$HOME/.config/subfinder/provider-config.yaml` file which will be created when you run the tool for the first time. The configuration file uses the YAML format. Multiple API keys +These values are stored in the `$CONFIG/subfinder/provider-config.yaml` file which will be created when you run the tool for the first time. The configuration file uses the YAML format. Multiple API keys can be specified for each of these services from which one of them will be used for enumeration. Composite keys for sources like, `Censys`, `PassiveTotal`, `Fofa`, `Intellix` and `360quake`, need to be separated with a colon (`:`). @@ -241,7 +241,7 @@ docker run projectdiscovery/subfinder:latest -d hackerone.com Running `subfinder` using the docker image, with a local config file: ```sh -docker run -v $HOME/.config/subfinder:/root/.config/subfinder -t projectdiscovery/subfinder -d hackerone.com +docker run -v $CONFIG/subfinder:/root/.config/subfinder -t projectdiscovery/subfinder -d hackerone.com ``` diff --git a/v2/pkg/runner/config.go b/v2/pkg/runner/config.go index 1f4a10da1..6c8ed2c6f 100644 --- a/v2/pkg/runner/config.go +++ b/v2/pkg/runner/config.go @@ -11,25 +11,6 @@ import ( fileutil "github.com/projectdiscovery/utils/file" ) -// GetConfigDirectory gets the subfinder config directory for a user -func GetConfigDirectory() (string, error) { - var config string - - directory, err := os.UserHomeDir() - if err != nil { - return config, err - } - config = directory + "/.config/subfinder" - - // Create All directory for subfinder even if they exist - err = os.MkdirAll(config, os.ModePerm) - if err != nil { - return config, err - } - - return config, nil -} - // createProviderConfigYAML marshals the input map to the given location on the disk func createProviderConfigYAML(configFilePath string) error { configFile, err := os.Create(configFilePath) diff --git a/v2/pkg/runner/config_test.go b/v2/pkg/runner/config_test.go deleted file mode 100644 index b0c36549d..000000000 --- a/v2/pkg/runner/config_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package runner - -import ( - "github.com/stretchr/testify/require" - "os" - "testing" -) - -func TestConfigGetDirectory(t *testing.T) { - directory, err := GetConfigDirectory() - if err != nil { - t.Fatalf("Expected nil got %v while getting home\n", err) - } - home, err := os.UserHomeDir() - if err != nil { - t.Fatalf("Expected nil got %v while getting dir\n", err) - } - config := home + "/.config/subfinder" - - require.Equal(t, directory, config, "Directory and config should be equal") -} diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index 2fe1bf4a4..72bd4801c 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -21,8 +21,9 @@ import ( ) var ( - defaultConfigLocation = filepath.Join(folderutil.AppConfigDirOrDefault(".", "subfinder"), "config.yaml") - defaultProviderConfigLocation = filepath.Join(folderutil.AppConfigDirOrDefault(".", "subfinder"), "provider-config.yaml") + configDir = folderutil.AppConfigDirOrDefault(".", "subfinder") + defaultConfigLocation = filepath.Join(configDir, "config.yaml") + defaultProviderConfigLocation = filepath.Join(configDir, "provider-config.yaml") ) // Options contains the configuration options for tuning @@ -169,6 +170,7 @@ func ParseOptions() *Options { if options.Version { gologger.Info().Msgf("Current Version: %s\n", version) + gologger.Info().Msgf("Subfinder Config Directory: %s", configDir) os.Exit(0) }