Skip to content

Commit

Permalink
Merge pull request #40 from ddosify/proxy_latency
Browse files Browse the repository at this point in the history
Proxy latency
  • Loading branch information
kursataktas authored Jan 17, 2022
2 parents 477d6ae + 23a4e20 commit d21a091
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ddosify [FLAG]
| `-n` | Total request count | `int` | `100` | No |
| `-d` | Test duration in seconds. | `int` | `10` | No |
| `-p` | Protocol of the request. Supported protocols are *HTTP, HTTPS*. HTTP/2 support is only available by using a config file as described. More protocols will be added. | `string` | `HTTPS` | No |
| `-m` | Request method. Available methods for HTTP(s) are *GET, POST, PUT, DELETE, UPDATE, PATCH* | `string` | `GET` | No |
| `-m` | Request method. Available methods for HTTP(s) are *GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS* | `string` | `GET` | No |
| `-b` | The payload of the network packet. AKA body for the HTTP. | `string` | - | No |
| `-a` | Basic authentication. Usage: `-a username:password` | `string` | - | No |
| `-h` | Headers of the request. You can provide multiple headers with multiple `-h` flag. | `string`| - | No |
Expand Down
1 change: 1 addition & 0 deletions core/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func (e *engine) runWorker(scenarioStartTime time.Time) {
res.Others = make(map[string]interface{})
res.Others["hammerOthers"] = e.hammer.Others
res.Others["proxyCountry"] = e.proxyService.GetProxyCountry(p)
res.Others["proxyLatency"] = e.proxyService.GetLatency(p)
e.responseChan <- res
}

Expand Down
2 changes: 2 additions & 0 deletions core/proxy/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"net/url"
"reflect"
"time"
)

var AvailableProxyServices = make(map[string]ProxyService)
Expand All @@ -48,6 +49,7 @@ type ProxyService interface {
GetProxy() *url.URL
ReportProxy(addr *url.URL, reason string) *url.URL
GetProxyCountry(*url.URL) string
GetLatency(*url.URL) time.Duration
Done() error
}

Expand Down
6 changes: 6 additions & 0 deletions core/proxy/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package proxy

import (
"net/url"
"time"
)

const ProxyTypeSingle = "single"
Expand Down Expand Up @@ -57,6 +58,11 @@ func (sp *singleProxyStrategy) GetProxyCountry(addr *url.URL) string {
return "unknown"
}

func (sp *singleProxyStrategy) GetLatency(addr *url.URL) time.Duration {
// We may want to calculate latency for single proxy strategy also.
return time.Duration(0)
}

func (sp *singleProxyStrategy) Done() error {
return nil
}
2 changes: 1 addition & 1 deletion core/scenario/requester/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (h *HttpRequester) Send() (res *types.ResponseItem) {
StatusCode: statusCode,
RequestTime: reqStartTime,
Duration: durations.totalDuration(),
ContentLenth: contentLength,
ContentLength: contentLength,
Err: requestErr,
Custom: map[string]interface{}{
"dnsDuration": durations.getDNSDur(),
Expand Down
2 changes: 1 addition & 1 deletion core/types/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type ResponseItem struct {
Duration time.Duration

// Response content length
ContentLenth int64
ContentLength int64

// Error occurred at request time.
Err RequestError
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
duration = flag.Int("d", types.DefaultDuration, "Test duration in seconds")
loadType = flag.String("l", types.DefaultLoadType, "Type of the load test [linear, incremental, waved]")

protocol = flag.String("p", types.DefaultProtocol, "[HTTP, HTTPS]")
protocol = flag.String("p", types.DefaultProtocol, "Protocol [HTTP, HTTPS]")
method = flag.String("m", types.DefaultMethod,
"Request Method Type. For Http(s):[GET, POST, PUT, DELETE, UPDATE, PATCH]")
payload = flag.String("b", "", "Payload of the network packet")
Expand Down

0 comments on commit d21a091

Please sign in to comment.