52 Commits

Author SHA1 Message Date
a9021bd1a4 Merge pull request #80 from aykhans/refactor/color-utils
Some checks failed
golangci-lint / lint (push) Failing after 42s
🔨 Replace color utils with 'github.com/fatih/color'
2025-03-02 20:22:43 +04:00
48c2dc7935 🔖 bump version to 0.5.7 2025-03-02 20:20:06 +04:00
4cb0540824 🔨 Replace color utils with 'github.com/fatih/color' 2025-03-02 20:18:11 +04:00
a01bf19986 Merge pull request #79 from aykhans/bump/go-version
Some checks failed
golangci-lint / lint (push) Failing after 39s
🔖 Bump go version to 1.24
2025-03-01 17:20:56 +04:00
74dcecc8b1 🔖 Bump go version to 1.24 2025-03-01 17:18:59 +04:00
00afca7139 Merge pull request #77 from aykhans/feat/add-makefile
Some checks failed
golangci-lint / lint (push) Failing after 2m11s
🔧 Added Makefile
2025-02-28 03:43:33 +04:00
1589fefeb8 🔧 Added Makefile 2025-02-28 03:41:33 +04:00
bbc43bbaac Merge pull request #75 from aykhans/ci/add-golangci-lint
Added golangci lint to CI
2025-02-28 03:27:14 +04:00
89fcf5f174 Merge branch 'ci/add-golangci-lint' of https://github.com/aykhans/dodo into ci/add-golangci-lint 2025-02-28 03:25:29 +04:00
a58f734a55 Merge branch 'main' into ci/add-golangci-lint 2025-02-28 03:23:06 +04:00
efd5176ab9 Merge pull request #76 from aykhans/refactor/general-refactoring
🔨 Remove unnecessary conversions
2025-02-28 03:21:26 +04:00
f0adcaf328 👷 Update golangci-lint.yml 2025-02-28 03:18:50 +04:00
6314cf7724 🐳 '.golangci.yml' added to .dockerignore 2025-02-28 03:16:03 +04:00
140e570b85 👷 Added golangci-lint 2025-02-28 03:15:33 +04:00
83c5788e54 🔨 Remove unnecessary conversions 2025-02-28 02:16:04 +04:00
ca74092615 Merge pull request #74 from aykhans/dependabot/go_modules/github.com/valyala/fasthttp-1.59.0
Bump github.com/valyala/fasthttp from 1.58.0 to 1.59.0
2025-02-20 20:41:41 +04:00
004b10ea3c Bump github.com/valyala/fasthttp from 1.58.0 to 1.59.0
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.58.0 to 1.59.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.58.0...v1.59.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-20 00:53:09 +00:00
4c9ceb1c4b Merge pull request #73 from aykhans/dependabot/go_modules/github.com/go-playground/validator/v10-10.25.0
Bump github.com/go-playground/validator/v10 from 10.24.0 to 10.25.0
2025-02-17 15:17:27 +04:00
6f3df7c45b Bump github.com/go-playground/validator/v10 from 10.24.0 to 10.25.0
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.24.0 to 10.25.0.
- [Release notes](https://github.com/go-playground/validator/releases)
- [Commits](https://github.com/go-playground/validator/compare/v10.24.0...v10.25.0)

---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-17 00:34:54 +00:00
8cd495055d Merge pull request #71 from aykhans/dependabot/go_modules/github.com/jedib0t/go-pretty/v6-6.6.6
Bump github.com/jedib0t/go-pretty/v6 from 6.6.5 to 6.6.6
2025-02-11 19:45:45 +04:00
391a5bc6ec Bump github.com/jedib0t/go-pretty/v6 from 6.6.5 to 6.6.6
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.6.5 to 6.6.6.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.6.5...v6.6.6)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 15:44:47 +00:00
a69e248f8c Merge pull request #72 from aykhans/dependabot/go_modules/golang.org/x/net-0.35.0
Bump golang.org/x/net from 0.34.0 to 0.35.0
2025-02-11 19:43:31 +04:00
2634ca110c Bump golang.org/x/net from 0.34.0 to 0.35.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.34.0 to 0.35.0.
- [Commits](https://github.com/golang/net/compare/v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 00:48:51 +00:00
b1612598c4 Merge pull request #70 from aykhans/docs/update
Docs/update
2025-01-21 20:53:30 +04:00
ba79304b04 📚 Update README.md 2025-01-21 20:52:25 +04:00
015cb15053 📚 Update docs 2025-01-21 20:50:10 +04:00
3dc002188e 📚 Update docs 2025-01-21 20:47:01 +04:00
769c04685a Merge pull request #69 from aykhans/fix/connections-bottleneck
🐛 Remove 'CloseIdleConnections' from 'Send' function
2025-01-15 21:44:02 +04:00
e43378a9a4 🔖 bump version to 0.5.6 2025-01-15 21:43:46 +04:00
e29e4f1bc6 🐛 Remove 'CloseIdleConnections' from 'Send' function 2025-01-14 20:43:45 +04:00
7d2168a014 Merge pull request #67 from aykhans/dependabot/go_modules/github.com/go-playground/validator/v10-10.24.0
Bump github.com/go-playground/validator/v10 from 10.23.0 to 10.24.0
2025-01-14 16:29:25 +04:00
ba53e6b7f7 Bump github.com/go-playground/validator/v10 from 10.23.0 to 10.24.0
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.23.0 to 10.24.0.
- [Release notes](https://github.com/go-playground/validator/releases)
- [Commits](https://github.com/go-playground/validator/compare/v10.23.0...v10.24.0)

---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-14 00:26:46 +00:00
58964e1098 Merge pull request #66 from aykhans/dependabot/go_modules/golang.org/x/net-0.34.0
Bump golang.org/x/net from 0.33.0 to 0.34.0
2025-01-08 15:27:52 +04:00
d4bf7358ff Bump golang.org/x/net from 0.33.0 to 0.34.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.33.0 to 0.34.0.
- [Commits](https://github.com/golang/net/compare/v0.33.0...v0.34.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-07 00:38:29 +00:00
779d5e9b18 Merge pull request #65 from aykhans/refactor/rename-cli-flags
🔨 Rename CLI flags
2025-01-03 13:27:24 +04:00
6a79d0b1d7 🔖 bump version to 0.5.502 2025-01-03 13:26:34 +04:00
1e53b8a7fb 📚 Update docs 2025-01-03 13:26:00 +04:00
0a8dbec739 🔨 Renama JSON parameters 2025-01-03 13:17:20 +04:00
3762890914 🔨 Rename CLI flags 2025-01-03 13:14:25 +04:00
ca6b3d4eb2 Merge pull request #64 from aykhans/bump/version
🔖 Bump version to 0.5.501
2024-12-25 02:08:59 +04:00
1ee06aacc3 🔖 Bump version to 0.5.501 2024-12-25 02:08:47 +04:00
3d5834a6a6 Merge pull request #63 from aykhans/fix/empty-slice
🐛 Return empty brackets instead of null when slice length is 0
2024-12-25 01:24:28 +04:00
f1521cbb74 💄 Update config table 2024-12-23 18:58:22 +04:00
40f8a1cc37 🐛 Return empty brackets instead of null when slice length is 0 2024-12-22 23:15:10 +04:00
8a3574cd48 Merge pull request #62 from aykhans/bumg/version
🔖 Bump version to v0.5.5
2024-12-22 22:03:09 +04:00
5a2a4c47b2 🔖 Bump version to v0.5.5 2024-12-22 22:02:57 +04:00
ff09a3365e Merge pull request #61 from aykhans/dependabot/go_modules/golang.org/x/net-0.33.0
Bump golang.org/x/net from 0.32.0 to 0.33.0
2024-12-20 18:17:30 +04:00
c83246abe4 Merge pull request #60 from aykhans/refactor/json-marshal
Refactor json marshal
2024-12-20 18:17:11 +04:00
efc4c62001 📚 Update docs 2024-12-20 18:16:25 +04:00
f567774e3a Bump golang.org/x/net from 0.32.0 to 0.33.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.32.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 01:01:35 +00:00
d2bd60e3ff 🔨 Add custom 'WidthMaxEnforcer' to the table config 2024-12-20 01:21:26 +04:00
0fe782c768 🔨 Add 'PrettyJSONMarshal' function 2024-12-20 01:20:45 +04:00
17 changed files with 260 additions and 160 deletions

View File

@ -4,6 +4,7 @@ binaries
dodo
.git
.gitignore
.golangci.yml
README.md
LICENSE
config.json

25
.github/workflows/golangci-lint.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64
args: --timeout=10m --config=.golangci.yml

27
.golangci.yml Normal file
View File

@ -0,0 +1,27 @@
run:
go: "1.24"
concurrency: 8
timeout: 10m
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- gofmt
- goimports
- gomodguard
- goprintffuncname
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- prealloc
- reassign
- staticcheck
- typecheck
- unconvert
- unused
- whitespace

View File

@ -1,4 +1,4 @@
FROM golang:1.23.2-alpine AS builder
FROM golang:1.24-alpine AS builder
WORKDIR /dodo

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
lint:
golangci-lint run
build:
go build -ldflags "-s -w" -o "./dodo"
build-all:
rm -rf ./binaries
./build.sh

View File

@ -54,18 +54,32 @@ docker run --rm -i aykhans/dodo -u https://example.com -m GET -d 10 -r 1000 -t 2
### 2. JSON config file
You can find an example config structure in the [config.json](https://github.com/aykhans/dodo/blob/main/config.json) file:
```json
```jsonc
{
"method": "GET",
"url": "https://example.com",
"no_proxy_check": false,
"timeout": 10000,
"dodos_count": 1,
"request_count": 1,
"params": {},
"headers": {},
"cookies": {},
"body": [],
"dodos": 1,
"requests": 1,
"params": {
// Random param value will be selected from the param-key1 and param-key2 list for each request
"param-key1": ["param-value1", "param-value2", "param-value3"],
"param-key2": ["param-value1", "param-value2", "param-value3"]
},
"headers": {
// Random header value will be selected from the header-key1 and header-key2 list for each request
"header-key1": ["header-value1", "header-value2", "header-value3"],
"header-key2": ["header-value2", "header-value2", "header-value3"]
},
"cookies": {
// Random cookie value will be selected from the cookie-key1 and cookie-key2 list for each request
"cookie-key1": ["cookie-value1", "cookie-value2", "cookie-value3"],
"cookie-key2": ["cookie-value2", "cookie-value2", "cookie-value3"]
},
// Random body value will be selected from the body list for each request
"body": ["body1", "body2", "body3"],
// Random proxy will be selected from the proxy list for each request
"proxies": [
{
"url": "http://example.com:8080",
@ -108,8 +122,8 @@ If the Headers, Params, Cookies and Body fields have multiple values, each reque
| Yes | - | --yes | -y | Boolean | Answer yes to all questions | false |
| URL | url | --url | -u | String | URL to send the request to | - |
| Method | method | --method | -m | String | HTTP method | GET |
| Request count | request_count | --request-count | -r | Integer | Total number of requests to send | 1000 |
| Dodos count (Threads) | dodos_count | --dodos-count | -d | Integer | Number of dodos (threads) to send requests in parallel | 1 |
| Requests | requests | --requests | -r | Integer | Total number of requests to send | 1000 |
| Dodos (Threads) | dodos | --dodos | -d | Integer | Number of dodos (threads) to send requests in parallel | 1 |
| Timeout | timeout | --timeout | -t | Integer | Timeout for canceling each request (milliseconds) | 10000 |
| No Proxy Check | no_proxy_check | --no-proxy-check| - | Boolean | Disable proxy check | false |
| Params | params | - | - | Key-Value {String: [String]} | Request parameters | - |

View File

@ -3,12 +3,21 @@
"url": "https://example.com",
"no_proxy_check": false,
"timeout": 10000,
"dodos_count": 1,
"request_count": 1,
"params": {},
"headers": {},
"cookies": {},
"body": [],
"dodos": 1,
"requests": 1,
"params": {
"param-key1": ["param-value1", "param-value2", "param-value3"],
"param-key2": ["param-value1", "param-value2", "param-value3"]
},
"headers": {
"header-key1": ["header-value1", "header-value2", "header-value3"],
"header-key2": ["header-value2", "header-value2", "header-value3"]
},
"cookies": {
"cookie-key1": ["cookie-value1", "cookie-value2", "cookie-value3"],
"cookie-key2": ["cookie-value2", "cookie-value2", "cookie-value3"]
},
"body": ["body1", "body2", "body3"],
"proxies": [
{
"url": "http://example.com:8080",

View File

@ -1,9 +1,9 @@
package config
import (
"fmt"
"net/url"
"os"
"strings"
"time"
. "github.com/aykhans/dodo/types"
@ -12,7 +12,7 @@ import (
)
const (
VERSION string = "0.5.4"
VERSION string = "0.5.7"
DefaultUserAgent string = "Dodo/" + VERSION
ProxyCheckURL string = "https://www.google.com"
DefaultMethod string = "GET"
@ -42,7 +42,18 @@ func (config *RequestConfig) Print() {
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleLight)
t.SetColumnConfigs([]table.ColumnConfig{
{Number: 2, WidthMax: 50},
{
Number: 2,
WidthMaxEnforcer: func(col string, maxLen int) string {
lines := strings.Split(col, "\n")
for i, line := range lines {
if len(line) > maxLen {
lines[i] = line[:maxLen-3] + "..."
}
}
return strings.Join(lines, "\n")
},
WidthMax: 50},
})
newHeaders := make(map[string][]string)
@ -56,23 +67,23 @@ func (config *RequestConfig) Print() {
t.AppendSeparator()
t.AppendRow(table.Row{"URL", config.URL})
t.AppendSeparator()
t.AppendRow(table.Row{"Timeout", fmt.Sprintf("%dms", config.Timeout/time.Millisecond)})
t.AppendRow(table.Row{"Timeout", config.Timeout})
t.AppendSeparator()
t.AppendRow(table.Row{"Dodos", config.DodosCount})
t.AppendSeparator()
t.AppendRow(table.Row{"Requests", config.RequestCount})
t.AppendSeparator()
t.AppendRow(table.Row{"Params", utils.MarshalJSON(config.Params, 3)})
t.AppendRow(table.Row{"Params", string(utils.PrettyJSONMarshal(config.Params, 3, "", " "))})
t.AppendSeparator()
t.AppendRow(table.Row{"Headers", utils.MarshalJSON(newHeaders, 3)})
t.AppendRow(table.Row{"Headers", string(utils.PrettyJSONMarshal(newHeaders, 3, "", " "))})
t.AppendSeparator()
t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)})
t.AppendRow(table.Row{"Cookies", string(utils.PrettyJSONMarshal(config.Cookies, 3, "", " "))})
t.AppendSeparator()
t.AppendRow(table.Row{"Proxies Count", len(config.Proxies)})
t.AppendRow(table.Row{"Proxies", string(utils.PrettyJSONMarshal(config.Proxies, 3, "", " "))})
t.AppendSeparator()
t.AppendRow(table.Row{"Proxy Check", !config.NoProxyCheck})
t.AppendSeparator()
t.AppendRow(table.Row{"Body", utils.MarshalJSON(config.Body, 3)})
t.AppendRow(table.Row{"Body", string(utils.PrettyJSONMarshal(config.Body, 3, "", " "))})
t.Render()
}
@ -87,7 +98,7 @@ func (config *RequestConfig) GetValidDodosCountForProxies() uint {
func (config *RequestConfig) GetMaxConns(minConns uint) uint {
maxConns := max(
minConns, uint(config.GetValidDodosCountForRequests()),
minConns, config.GetValidDodosCountForRequests(),
)
return ((maxConns * 50 / 100) + maxConns)
}
@ -96,8 +107,8 @@ type Config struct {
Method string `json:"method" validate:"http_method"` // custom validations: http_method
URL string `json:"url" validate:"http_url,required"`
Timeout uint32 `json:"timeout" validate:"gte=1,lte=100000"`
DodosCount uint `json:"dodos_count" validate:"gte=1"`
RequestCount uint `json:"request_count" validation_name:"request-count" validate:"gte=1"`
DodosCount uint `json:"dodos" validate:"gte=1"`
RequestCount uint `json:"requests" validation_name:"request-count" validate:"gte=1"`
NoProxyCheck Option[bool] `json:"no_proxy_check"`
}

28
go.mod
View File

@ -1,26 +1,32 @@
module github.com/aykhans/dodo
go 1.23.2
go 1.24
require (
github.com/go-playground/validator/v10 v10.23.0
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/valyala/fasthttp v1.58.0
golang.org/x/net v0.32.0
github.com/go-playground/validator/v10 v10.25.0
github.com/jedib0t/go-pretty/v6 v6.6.6
github.com/valyala/fasthttp v1.59.0
golang.org/x/net v0.35.0
)
require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
)
require (
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/fatih/color v1.18.0
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
)

53
go.sum
View File

@ -2,46 +2,55 @@ github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7X
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3NgSqAo=
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
github.com/jedib0t/go-pretty/v6 v6.6.6 h1:LyezkL+1SuqH2z47e5IMQkYUIcs2BD+MnpdPRiRcN0c=
github.com/jedib0t/go-pretty/v6 v6.6.6/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.58.0 h1:GGB2dWxSbEprU9j0iMJHgdKYJVDyjrOwF9RE59PbRuE=
github.com/valyala/fasthttp v1.58.0/go.mod h1:SYXvHHaFp7QZHGKSHmoMipInhrI5StHrhDTYVEjK/Kw=
github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI=
github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -16,6 +16,7 @@ import (
"github.com/aykhans/dodo/requests"
"github.com/aykhans/dodo/utils"
"github.com/aykhans/dodo/validation"
"github.com/fatih/color"
goValidator "github.com/go-playground/validator/v10"
)
@ -109,13 +110,13 @@ func main() {
responses, err := requests.Run(ctx, requestConf)
if err != nil {
if customerrors.Is(err, customerrors.ErrInterrupt) {
utils.PrintlnC(utils.Colors.Yellow, err.Error())
color.Yellow(err.Error())
return
} else if customerrors.Is(err, customerrors.ErrNoInternet) {
utils.PrintAndExit("No internet connection")
return
}
panic(err)
utils.PrintErrAndExit(err)
}
responses.Print()

View File

@ -7,7 +7,7 @@ import (
"github.com/aykhans/dodo/config"
. "github.com/aykhans/dodo/types"
"github.com/aykhans/dodo/utils"
"github.com/fatih/color"
)
const usageText = `Usage:
@ -28,9 +28,9 @@ Flags:
-h, --help help for dodo
-v, --version version for dodo
-c, --config-file string Path to the config file
-d, --dodos-count uint Number of dodos(threads) (default %d)
-d, --dodos uint Number of dodos(threads) (default %d)
-m, --method string HTTP Method (default %s)
-r, --request-count uint Number of total requests (default %d)
-r, --request uint Number of total requests (default %d)
-t, --timeout uint32 Timeout for each request in milliseconds (default %d)
-u, --url string URL for stress testing
--no-proxy-check bool Do not check for proxies (default false)
@ -74,10 +74,10 @@ func CLIConfigReader() (*config.CLIConfig, error) {
flag.StringVar(&url, "url", "", "URL to send the request")
flag.StringVar(&url, "u", "", "URL to send the request")
flag.UintVar(&dodosCount, "dodos-count", 0, "Number of dodos(threads)")
flag.UintVar(&dodosCount, "dodos", 0, "Number of dodos(threads)")
flag.UintVar(&dodosCount, "d", 0, "Number of dodos(threads)")
flag.UintVar(&requestsCount, "requests-count", 0, "Number of total requests")
flag.UintVar(&requestsCount, "requests", 0, "Number of total requests")
flag.UintVar(&requestsCount, "r", 0, "Number of total requests")
flag.UintVar(&timeout, "timeout", 0, "Timeout for each request in milliseconds")
@ -107,14 +107,14 @@ func CLIConfigReader() (*config.CLIConfig, error) {
cliConfig.Method = method
case "url", "u":
cliConfig.URL = url
case "dodos-count", "d":
case "dodos", "d":
cliConfig.DodosCount = dodosCount
case "requests-count", "r":
case "requests", "r":
cliConfig.RequestCount = requestsCount
case "timeout", "t":
var maxUint32 uint = 4294967295
if timeout > maxUint32 {
utils.PrintfC(utils.Colors.Yellow, "timeout value is too large, setting to %d\n", maxUint32)
color.Yellow("timeout value is too large, setting to %d", maxUint32)
timeout = maxUint32
}
cliConfig.Timeout = uint32(timeout)

View File

@ -11,6 +11,7 @@ import (
"github.com/aykhans/dodo/config"
"github.com/aykhans/dodo/readers"
"github.com/aykhans/dodo/utils"
"github.com/fatih/color"
"github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttpproxy"
)
@ -73,18 +74,9 @@ func getClients(
var yesOrNoDefault bool
if activeProxyClientsCount == 0 {
yesOrNoDefault = false
yesOrNoMessage = utils.Colored(
utils.Colors.Yellow,
"No active proxies found. Do you want to continue?",
)
yesOrNoMessage = color.YellowString("No active proxies found. Do you want to continue?")
} else {
yesOrNoMessage = utils.Colored(
utils.Colors.Yellow,
fmt.Sprintf(
"Found %d active proxies. Do you want to continue?",
activeProxyClientsCount,
),
)
yesOrNoMessage = color.YellowString("Found %d active proxies. Do you want to continue?", activeProxyClientsCount)
}
if !yes {
response := readers.CLIYesOrNoReader("\n"+yesOrNoMessage, yesOrNoDefault)

View File

@ -26,7 +26,6 @@ type Request struct {
func (r *Request) Send(ctx context.Context, timeout time.Duration) (*fasthttp.Response, error) {
client := r.getClient()
request := r.getRequest()
defer client.CloseIdleConnections()
defer fasthttp.ReleaseRequest(request)
response := fasthttp.AcquireResponse()

View File

@ -75,7 +75,7 @@ func releaseDodos(
requestCountPerDodo uint
dodosCount uint = requestConfig.GetValidDodosCountForRequests()
dodosCountInt int = int(dodosCount)
requestCount uint = uint(requestConfig.RequestCount)
requestCount uint = requestConfig.RequestCount
responses = make([][]*Response, dodosCount)
increase = make(chan int64, requestCount)
)

View File

@ -6,49 +6,80 @@ import (
"reflect"
)
func MarshalJSON(v any, maxSliceSize uint) string {
rv := reflect.ValueOf(v)
if rv.Kind() == reflect.Slice && rv.Len() == 0 {
return "[]"
}
data, err := json.MarshalIndent(truncateLists(v, int(maxSliceSize)), "", " ")
if err != nil {
return "{}"
}
return string(data)
type TruncatedMarshaller struct {
Value interface{}
MaxItems int
}
func truncateLists(v interface{}, maxItems int) interface{} {
rv := reflect.ValueOf(v)
func (t TruncatedMarshaller) MarshalJSON() ([]byte, error) {
val := reflect.ValueOf(t.Value)
switch rv.Kind() {
case reflect.Slice, reflect.Array:
if rv.Len() > maxItems {
newSlice := reflect.MakeSlice(rv.Type(), maxItems, maxItems)
reflect.Copy(newSlice, rv.Slice(0, maxItems))
newSlice = reflect.Append(newSlice, reflect.ValueOf(fmt.Sprintf("...(%d more)", rv.Len()-maxItems)))
return newSlice.Interface()
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
return json.Marshal(t.Value)
}
if val.Len() == 0 {
return []byte("[]"), nil
}
length := val.Len()
if length <= t.MaxItems {
return json.Marshal(t.Value)
}
truncated := make([]interface{}, t.MaxItems+1)
for i := 0; i < t.MaxItems; i++ {
truncated[i] = val.Index(i).Interface()
}
remaining := length - t.MaxItems
truncated[t.MaxItems] = fmt.Sprintf("+%d", remaining)
return json.Marshal(truncated)
}
func PrettyJSONMarshal(v interface{}, maxItems int, prefix, indent string) []byte {
truncated := processValue(v, maxItems)
d, _ := json.MarshalIndent(truncated, prefix, indent)
return d
}
func processValue(v interface{}, maxItems int) interface{} {
val := reflect.ValueOf(v)
switch val.Kind() {
case reflect.Map:
newMap := reflect.MakeMap(rv.Type())
for _, key := range rv.MapKeys() {
newMap.SetMapIndex(key, reflect.ValueOf(truncateLists(rv.MapIndex(key).Interface(), maxItems)))
}
return newMap.Interface()
case reflect.Struct:
newStruct := reflect.New(rv.Type()).Elem()
for i := 0; i < rv.NumField(); i++ {
newStruct.Field(i).Set(reflect.ValueOf(truncateLists(rv.Field(i).Interface(), maxItems)))
}
return newStruct.Interface()
case reflect.Ptr:
if rv.IsNil() {
return nil
}
return truncateLists(rv.Elem().Interface(), maxItems)
newMap := make(map[string]interface{})
iter := val.MapRange()
for iter.Next() {
k := iter.Key().String()
newMap[k] = processValue(iter.Value().Interface(), maxItems)
}
return newMap
case reflect.Slice, reflect.Array:
return TruncatedMarshaller{Value: v, MaxItems: maxItems}
case reflect.Struct:
newMap := make(map[string]interface{})
t := val.Type()
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
if field.IsExported() {
jsonTag := field.Tag.Get("json")
if jsonTag == "-" {
continue
}
fieldName := field.Name
if jsonTag != "" {
fieldName = jsonTag
}
newMap[fieldName] = processValue(val.Field(i).Interface(), maxItems)
}
}
return newMap
default:
return v
}
}

View File

@ -3,46 +3,12 @@ package utils
import (
"fmt"
"os"
"github.com/fatih/color"
)
var Colors = struct {
reset string
Red string
Green string
Yellow string
Orange string
Blue string
Magenta string
Cyan string
Gray string
White string
}{
reset: "\033[0m",
Red: "\033[31m",
Green: "\033[32m",
Yellow: "\033[33m",
Orange: "\033[38;5;208m",
Blue: "\033[34m",
Magenta: "\033[35m",
Cyan: "\033[36m",
Gray: "\033[37m",
White: "\033[97m",
}
func Colored(color string, a ...any) string {
return color + fmt.Sprint(a...) + Colors.reset
}
func PrintfC(color string, format string, a ...any) {
fmt.Printf(Colored(color, format), a...)
}
func PrintlnC(color string, a ...any) {
fmt.Println(Colored(color, a...))
}
func PrintErr(err error) {
PrintlnC(Colors.Red, err.Error())
color.New(color.FgRed).Fprintln(os.Stderr, err.Error())
}
func PrintErrAndExit(err error) {