Documentation
¶
Index ¶
Constants ¶
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
const ( // Constants of the Load Types LoadTypeLinear = "linear" LoadTypeIncremental = "incremental" LoadTypeWaved = "waved" // 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
const ( // Constants of the Protocol types ProtocolHTTP = "HTTP" ProtocolHTTPS = "HTTPS" // Constants of the Auth types AuthHttpBasic = "basic" )
Constants for Scenario field values
Variables ¶
var SupportedProtocols = [...]string{ProtocolHTTP, ProtocolHTTPS}
SupportedProtocols should be updated whenever a new requester.Requester interface implemented
Functions ¶
func AdjustUrlProtocol ¶ added in v0.8.0
AdjustUrlProtocol adjusts the proper url-proto pair for the given ones. If url includes protocol then the new protocol will be the protocol in the url If url does not include protocol, then the new url will include the given protocol If url is not valid, then error will be returned
Types ¶
type Auth ¶
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, ...} TimeRunCountMap TimeRunCount // 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[string]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.
type RequestError ¶
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[string]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 // Name of the ScenarioItem ScenarioItemName string // 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 ContentLength 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 // Name of the Item. Name string // 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 // Sleep duration after running the step. Can be a time range like "300-500" or an exact duration like "350" in ms Sleep string // 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.
type TimeRunCount ¶ added in v0.6.0
TimeRunCount is the data structure to store manual load type data.