Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions cmd/interactsh-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ func main() {
flagSet.BoolVarP(&healthcheck, "hc", "health-check", false, "run diagnostic check up"),
)

// If a custom config path is provided via -config, tell goflags before
// Parse() so it doesn't try to create/read the default config location.
for i := 1; i < len(os.Args); i++ {
if (os.Args[i] == "-config" || os.Args[i] == "--config") && i+1 < len(os.Args) {
flagSet.SetConfigFilePath(os.Args[i+1])
break
}
if strings.HasPrefix(os.Args[i], "-config=") || strings.HasPrefix(os.Args[i], "--config=") {
flagSet.SetConfigFilePath(strings.SplitN(os.Args[i], "=", 2)[1])
break
}
}

if err := flagSet.Parse(); err != nil {
gologger.Fatal().Msgf("Could not parse options: %s\n", err)
}
Expand Down Expand Up @@ -133,12 +146,6 @@ func main() {
}
}

if fileutil.FileExists(cliOptions.Config) {
if err := flagSet.MergeConfigFile(cliOptions.Config); err != nil {
gologger.Fatal().Msgf("Could not read config: %s\n", err)
}
}

var outputFile *os.File
var err error
if cliOptions.Output != "" {
Expand Down
19 changes: 13 additions & 6 deletions cmd/interactsh-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ func main() {
flagSet.BoolVarP(&cliOptions.Verbose, "verbose", "v", false, "display verbose interaction"),
)

// If a custom config path is provided via -config, tell goflags before
// Parse() so it doesn't try to create/read the default config location.
for i := 1; i < len(os.Args); i++ {
if (os.Args[i] == "-config" || os.Args[i] == "--config") && i+1 < len(os.Args) {
flagSet.SetConfigFilePath(os.Args[i+1])
break
}
if strings.HasPrefix(os.Args[i], "-config=") || strings.HasPrefix(os.Args[i], "--config=") {
flagSet.SetConfigFilePath(strings.SplitN(os.Args[i], "=", 2)[1])
break
}
}

if err := flagSet.Parse(); err != nil {
gologger.Fatal().Msgf("Could not parse options: %s\n", err)
}
Expand All @@ -136,12 +149,6 @@ func main() {
}
}

if cliOptions.Config != defaultConfigLocation {
if err := flagSet.MergeConfigFile(cliOptions.Config); err != nil {
gologger.Fatal().Msgf("Could not read config: %s\n", err)
}
}

if len(cliOptions.Domains) == 0 {
gologger.Fatal().Msgf("No domains specified\n")
}
Expand Down