types

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Types
	ErrorProxy    = "proxyError"
	ErrorConn     = "connectionError"
	ErrorUnkown   = "unkownError"
	ErrorIntented = "intentedError" // Errors for created intentionally

	// Reasons
	ReasonProxyFailed  = "proxy connection refused"
	ReasonProxyTimeout = "proxy timeout"
	ReasonConnTimeout  = "connection timeout"
	ReasonReadTimeout  = "read timeout"
	ReasonConnRefused  = "connection refused"

	// In gracefully stop, engine cancels the ongoing requests.
	// We can detect the canceled requests with the help of this.
	ReasonCtxCanceled = "context canceled"
)

Constants for custom error types and reasons

View Source
const (
	// Constants of the Load Types
	LoadTypeLinear      = "linear"
	LoadTypeIncremental = "incremental"
	LoadTypeWaved       = "waved"

	// To distinguish the received requests on the server side we are adding this special User-Agent to all requests
	DdosifyUserAgent = "DdosifyHammer"

	// Default Values
	DefaultReqCount   = 100
	DefaultLoadType   = LoadTypeLinear
	DefaultDuration   = 10
	DefaultTimeout    = 5
	DefaultProtocol   = ProtocolHTTPS
	DefaultMethod     = http.MethodGet
	DefaultOutputType = "stdout" // TODO: get this value from report.OutputTypeStdout when import cycle resolved.
)

Constants for Hammer field values

View Source
const (
	// Constants of the Protocol types
	ProtocolHTTP  = "HTTP"
	ProtocolHTTPS = "HTTPS"

	// Constants of the Auth types
	AuthHttpBasic = "basic"
)

Constants for Scenario field values

Variables

View Source
var SupportedProtocols = [...]string{ProtocolHTTP, ProtocolHTTPS}

SupportedProtocols should be updated whenever a new requester.Requester interface implemented

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Type     string
	Username string
	Password string
}

Auth struct should be able to include all necessary authentication realated data for supportedAuthentications.

type Hammer

type Hammer struct {
	// Total request count
	TotalReqCount int

	// Type of the load.
	LoadType string

	// Total Duration of the test in seconds.
	TestDuration int

	// Duration (in second) - Request count map. Example: {10: 1500, 50: 400, ...}
	TimeReqCountMap map[int]int

	// Test Scenario
	Scenario Scenario

	// Proxy/Proxies to use
	Proxy proxy.Proxy

	// Destination of the results data.
	ReportDestination string

	// Dynamic field for extra parameters.
	Others map[interface{}]interface{}
}

Hammer is like a lighter for the engine. It includes attack metadata and all necessary data to initialize the internal services in the engine.

func (*Hammer) Validate

func (h *Hammer) Validate() error

Validate validates attack metadata and executes the validation methods of the services.

type RequestError

type RequestError struct {
	Type   string
	Reason string
}

RequestError is our custom error struct created in the requester.Requester implementations.

func (*RequestError) Error

func (e *RequestError) Error() string

Custom error message method of RequestError

type Response

type Response struct {
	// First request start time for the Scenario
	StartTime time.Time

	ProxyAddr     *url.URL
	ResponseItems []*ResponseItem

	// Dynamic field for extra data needs in response object consumers.
	Others map[interface{}]interface{}
}

Response is corresponding to Scenario. Each Scenario has a Response after the request is done.

type ResponseItem

type ResponseItem struct {
	// ID of the ScenarioItem
	ScenarioItemID int16

	// Each request has a unique ID.
	RequestID uuid.UUID

	// Returned status code. Has different meaning for different protocols.
	StatusCode int

	// Time of the request call.
	RequestTime time.Time

	// Total duration. From request sending to full response receiving.
	Duration time.Duration

	// Response content length
	ContentLenth int64

	// Error occurred at request time.
	Err RequestError

	// Protocol spesific metrics. For ex: DNSLookupDuration: 1s for HTTP
	Custom map[string]interface{}
}

ResponseItem is corresponding to ScenarioItem.

type Scenario

type Scenario struct {
	Scenario []ScenarioItem
}

Scenario struct contains a list of ScenarioItem so scenario.ScenarioService can execute the scenario step by step.

type ScenarioItem

type ScenarioItem struct {
	// ID of the Item. Should be given by the client.
	ID int16

	// Protocol of the requests.
	Protocol string

	// Request Method
	Method string

	// Authentication
	Auth Auth

	// Request Headers
	Headers map[string]string

	// Request payload
	Payload string

	// Target URL
	URL string

	// Connection timeout duration of the request in seconds
	Timeout int

	// Protocol spesific request parameters. For ex: DisableRedirects:true for Http requests
	Custom map[string]interface{}
}

ScenarioItem represents one step of a Scenario. This struct should be able to include all necessary data in a network packet for SupportedProtocols.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL