Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( EventTCPDial = "tcp/dial" EventTCPClosed = "tcp/closed" EventWorkerError = "worker/error" EventWorkerPanic = "worker/panic" )
Variables ¶
This section is empty.
Functions ¶
func ErrorFromEvent ¶ added in v0.0.2
func WorkerIdFromEvent ¶ added in v0.0.2
Types ¶
type AsyncEventHandler ¶ added in v0.0.2
type AsyncEventHandler struct {
// contains filtered or unexported fields
}
func NewAsyncEventHandler ¶ added in v0.0.2
func NewAsyncEventHandler(h EventHandler, cap int) *AsyncEventHandler
func (*AsyncEventHandler) Close ¶ added in v0.0.2
func (f *AsyncEventHandler) Close() error
func (*AsyncEventHandler) HandleEvent ¶ added in v0.0.2
func (f *AsyncEventHandler) HandleEvent(event Event)
type Event ¶ added in v0.0.2
type Event struct {
// Name - event name
Name string
// At - event time
At time.Time
// Attrs - optional event attributes
Attrs map[string]any
}
Event represents an event.
func NewEvent ¶ added in v0.0.2
func NewEvent(eventName string, settings ...EventSettings) Event
NewEvent creates a new event.
type EventHandleFunc ¶ added in v0.0.2
type EventHandleFunc func(event Event)
func (EventHandleFunc) HandleEvent ¶ added in v0.0.2
func (f EventHandleFunc) HandleEvent(event Event)
type EventHandler ¶ added in v0.0.2
type EventHandler interface {
HandleEvent(event Event)
}
EventHandler handles events.
var NilEventHandler EventHandler = EventHandleFunc(func(event Event) {})
NilEventHandler is an event handler that does nothing.
type EventSettings ¶ added in v0.0.2
type EventSettings func(e *Event)
EventSettings configures an event.
func WithEventError ¶ added in v0.0.2
func WithEventError(err error) EventSettings
WithEventError binds the error of the event attrs.
func WithEventWorkerId ¶ added in v0.0.2
func WithEventWorkerId(workerId int) EventSettings
WithEventWorkerId binds the worker id of the event attrs.
type SlowBodyReadRequest ¶
type SlowBodyReadRequest struct {
Target Target `embed:""`
// Method - the HTTP method to use, one of POST / PUT. Defaults to POST.
Method string `name:"http-method" help:"the HTTP method to use, one of POST / PUT. Defaults to POST."`
// BodyReadTimeout - the timeout for reading the request body. Defaults to hang forever.
BodyReadTimeout time.Duration `name:"http-read-timeout" help:"the timeout for reading the request body. Defaults to hang forever."`
// contains filtered or unexported fields
}
SlowBodyReadRequest provides the configurations for simulating slow request body reading attack.
Example ¶
u, err := url.Parse("http://127.0.0.1:8080")
if err != nil {
panic(err)
}
s := SlowBodyReadRequest{
Target: Target{
Url: *u,
},
Method: http.MethodPost,
BodyReadTimeout: 180 * time.Second,
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_ = s.Run(ctx)
func (*SlowBodyReadRequest) AfterApply ¶ added in v0.0.2
func (s *SlowBodyReadRequest) AfterApply() error
type Slowloris ¶
type Slowloris struct {
Target Target `embed:""`
// Method - the HTTP method to use. Defaults to GET
Method string `name:"http-method" help:"the HTTP method to use. Defaults to GET"`
// UserAgents - list of user agents to use.
// If more than one is provided, a random one will be selected.
// If none is provided, a default one will be used.
UserAgents []string `` /* 167-byte string literal not displayed */
// SendGibberish - whether to send gibberish data in the request header.
SendGibberish bool `name:"http-send-gibberish" help:"whether to send gibberish data in the request header"`
// GibberishInterval - the random interval to send gibberish data in the request header. Defaults to 3s.
GibberishInterval time.Duration `name:"http-gibberish-interval" help:"the random interval to send gibberish data in the request header"`
// WriteTimeout - the timeout for writing the request header. Defaults to 10s.
WriteTimeout time.Duration `name:"http-write-timeout" help:"the timeout for writing the request header. Defaults to 10s."`
// contains filtered or unexported fields
}
Slowloris provides the configurations for running slowloris attack.
Example ¶
u, err := url.Parse("http://127.0.0.1:8080")
if err != nil {
panic(err)
}
s := Slowloris{
Target: Target{
Url: *u,
},
SendGibberish: true,
GibberishInterval: 5 * time.Millisecond,
UserAgents: []string{
"turtle/0.0.1",
"turtle/0.0.1 - slowloris",
},
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_ = s.Run(ctx)
func (*Slowloris) AfterApply ¶ added in v0.0.2
type Target ¶
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:"-"`
}
Target provides target configuration.
Click to show internal directories.
Click to hide internal directories.
