mirror of
https://github.com/aykhans/dodo.git
synced 2025-07-03 17:17:25 +00:00
Compare commits
4 Commits
v0.6.1
...
a170588574
Author | SHA1 | Date | |
---|---|---|---|
a170588574 | |||
2a0ac390d8 | |||
11bb8b3fb0 | |||
1aadc3419a |
25
README.md
25
README.md
@ -45,28 +45,11 @@ Download the latest binaries from the [releases](https://github.com/aykhans/dodo
|
|||||||
|
|
||||||
### Building from Source
|
### Building from Source
|
||||||
|
|
||||||
To build Dodo from source, ensure you have [Go 1.24+](https://golang.org/dl/) installed. Then follow these steps:
|
To build Dodo from source, ensure you have [Go 1.24+](https://golang.org/dl/) installed.
|
||||||
|
|
||||||
1. **Clone the repository:**
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/aykhans/dodo.git
|
go install -ldflags "-s -w" github.com/aykhans/dodo@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Navigate to the project directory:**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cd dodo
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Build the project:**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
go build -ldflags "-s -w" -o dodo
|
|
||||||
```
|
|
||||||
|
|
||||||
This will generate an executable named `dodo` in the project directory.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Dodo supports CLI arguments, configuration files (JSON/YAML), or a combination of both. If both are used, CLI arguments take precedence.
|
Dodo supports CLI arguments, configuration files (JSON/YAML), or a combination of both. If both are used, CLI arguments take precedence.
|
||||||
@ -87,10 +70,10 @@ docker run --rm -i aykhans/dodo -u https://example.com -m GET -d 10 -r 1000 -t 2
|
|||||||
|
|
||||||
### 2. Config File Usage
|
### 2. Config File Usage
|
||||||
|
|
||||||
#### 2.1 JSON Example
|
|
||||||
|
|
||||||
Send 1000 GET requests to https://example.com with 10 parallel dodos (threads) and a timeout of 800 milliseconds:
|
Send 1000 GET requests to https://example.com with 10 parallel dodos (threads) and a timeout of 800 milliseconds:
|
||||||
|
|
||||||
|
#### 2.1 JSON Example
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
|
@ -233,4 +233,5 @@ func (config *Config) SetDefaults() {
|
|||||||
if config.Yes == nil {
|
if config.Yes == nil {
|
||||||
config.Yes = utils.ToPtr(DefaultYes)
|
config.Yes = utils.ToPtr(DefaultYes)
|
||||||
}
|
}
|
||||||
|
config.Headers.SetIfNotExists("User-Agent", DefaultUserAgent)
|
||||||
}
|
}
|
||||||
|
@ -166,9 +166,6 @@ func setRequestHeaders(req *fasthttp.Request, headers []types.KeyValue[string, s
|
|||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
req.Header.Add(header.Key, header.Value)
|
req.Header.Add(header.Key, header.Value)
|
||||||
}
|
}
|
||||||
if req.Header.UserAgent() == nil {
|
|
||||||
req.Header.SetUserAgent(config.DefaultUserAgent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setRequestCookies adds the cookies of the given request with the provided key-value pairs.
|
// setRequestCookies adds the cookies of the given request with the provided key-value pairs.
|
||||||
|
@ -73,6 +73,15 @@ func (headers Headers) GetValue(key string) *[]string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (headers Headers) Has(key string) bool {
|
||||||
|
for i := range headers {
|
||||||
|
if headers[i].Key == key {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (headers *Headers) UnmarshalJSON(b []byte) error {
|
func (headers *Headers) UnmarshalJSON(b []byte) error {
|
||||||
var data []map[string]any
|
var data []map[string]any
|
||||||
if err := json.Unmarshal(b, &data); err != nil {
|
if err := json.Unmarshal(b, &data); err != nil {
|
||||||
@ -137,3 +146,11 @@ func (headers *Headers) Set(value string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (headers *Headers) SetIfNotExists(key string, value string) bool {
|
||||||
|
if headers.Has(key) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
*headers = append(*headers, KeyValue[string, []string]{Key: key, Value: []string{value}})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user