Skip to content

Commit

Permalink
Add sleep parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zer-far committed Jan 22, 2024
1 parent 67e0df8 commit 17813a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

var (
version = "v1.4.0"
version = "v1.5.0"

banner = fmt.Sprintf(`
__
Expand Down Expand Up @@ -50,6 +50,8 @@ var (
check bool
timeout int
timeoutDuration time.Duration
sleep int
sleepDuration time.Duration
c = &http.Client{
Timeout: timeoutDuration,
}
Expand Down Expand Up @@ -117,7 +119,7 @@ func get() {
func loop() {
for {
go get()
time.Sleep(1 * time.Millisecond) // sleep before sending request again
time.Sleep(sleepDuration) // sleep before sending request again
}
}

Expand All @@ -127,6 +129,7 @@ func main() {

flag.StringVar(&hostname, "hostname", "", "example: --hostname https://example.com")
flag.IntVar(&timeout, "timeout", 3000, "Timeout in milliseconds")
flag.IntVar(&sleep, "sleep", 1, "Sleep time in milliseconds")
flag.IntVar(&threads, "threads", 1, "Number of threads")
flag.BoolVar(&check, "check", false, "Enable IP address check")
flag.Parse()
Expand All @@ -146,7 +149,9 @@ func main() {
os.Exit(1)
}

// convert values to milliseconds
timeoutDuration = time.Duration(timeout) * time.Millisecond
sleepDuration = time.Duration(sleep) * time.Millisecond

color.Yellow.Println("Press control+c to stop")
time.Sleep(2 * time.Second)
Expand Down

0 comments on commit 17813a6

Please sign in to comment.