Skip to content

Commit 0d00435

Browse files
committed
feat: Add timeout option for slow connections
1 parent b822126 commit 0d00435

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

utils/hurricane.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ func (h *Hurricane) Request(url string) string {
4040
opts := retryablehttp.DefaultOptionsSpraying
4141
client := retryablehttp.NewClient(opts)
4242

43-
// Configurando o timeout diretamente no cliente HTTP interno
44-
client.HTTPClient.Timeout = 30 * time.Second
43+
client.HTTPClient.Timeout = time.Duration(OptionCmd.Timeout) * time.Second
4544

4645
resp, err := client.Get(url)
4746
if err != nil {
48-
panic(err)
47+
gologger.Fatal().Msgf("Could not get the response from the server: %s\n", err)
4948
}
5049

5150
bin, err := httputil.DumpResponse(resp, true)

utils/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type options struct {
1010
VtscoreValue string
1111
VtApiKey string
1212
Target string
13+
Timeout int
1314
Domain string
1415
Config string
1516
}

utils/parameters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func LoadParameters() {
3030
flagSet.BoolVar(&OptionCmd.Onlynetworks, "only-networks", false, "show only networks")
3131
flagSet.StringVar(&OptionCmd.Workflow, "workflow", "", "Workflow config")
3232
flagSet.StringVar(&OptionCmd.Target, "target", "", "IP Address or Network to query")
33+
flagSet.IntVar(&OptionCmd.Timeout, "timeout", 10, "Timeout in seconds")
3334
flagSet.BoolVar(&OptionCmd.Silent, "silent", false, "show silent output")
3435
flagSet.BoolVar(&OptionCmd.Verbose, "verbose", false, "show verbose output")
3536

0 commit comments

Comments
 (0)