-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
33 lines (28 loc) · 864 Bytes
/
options.go
File metadata and controls
33 lines (28 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package turtle
import (
"net/url"
"time"
)
// Target provides target configuration.
type Target struct {
// Url - the url of the target.
Url url.URL `arg:"" name:"target-url" help:"the url of the target"`
// Duration - the duration of the attack. Defaults to 30s.
Duration time.Duration `name:"target-duration" help:"the duration of the attack. Defaults to 30s"`
// Connections - the number of connections to be made. Defaults to 100.
Connections int `name:"target-connections" help:"the number of connections to be made. Defaults to 100"`
// EventHandler - optional event handler to use.
EventHandler EventHandler `kong:"-"`
}
func (t *Target) defaults() error {
if t.Duration <= 0 {
t.Duration = 30 * time.Second
}
if t.Connections < 1 {
t.Connections = 100
}
if isNil(t.EventHandler) {
t.EventHandler = NilEventHandler
}
return nil
}