mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-21 11:16:47 +00:00
Compare commits
10 Commits
8d7aae4a61
...
4f66db0d1b
Author | SHA1 | Date | |
---|---|---|---|
4f66db0d1b | |||
2e6110e54a | |||
48721b4ae7 | |||
fe4a93b394 | |||
e3cbe1e9b4 | |||
94211eb018 | |||
565079fe97 | |||
696176e611 | |||
9ea06593f9 | |||
7f7dc07f4c |
86
.github/workflows/publish-docker-image.yml
vendored
Normal file
86
.github/workflows/publish-docker-image.yml
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
name: publish-docker-image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
# Match stable and pre versions, such as 'v1.0.0', 'v0.23.0-a', 'v0.23.0-a.2', 'v0.23.0-b', 'v0.23.0-b.3'
|
||||||
|
- "v*.*.*"
|
||||||
|
- "v*.*.*-a"
|
||||||
|
- "v*.*.*-a.*"
|
||||||
|
- "v*.*.*-b"
|
||||||
|
- "v*.*.*-b.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-stable-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Extract build args
|
||||||
|
# Extract version number and check if it's an pre version
|
||||||
|
run: |
|
||||||
|
if [[ "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "PRE_RELEASE=false" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "PRE_RELEASE=true" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: aykhans
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
install: true
|
||||||
|
version: v0.9.1
|
||||||
|
|
||||||
|
# Metadata for stable versions
|
||||||
|
- name: Docker meta for stable
|
||||||
|
id: meta-stable
|
||||||
|
if: env.PRE_RELEASE == 'false'
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
aykhans/dodo
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}},value=${{ env.VERSION }}
|
||||||
|
type=raw,value=stable
|
||||||
|
flavor: |
|
||||||
|
latest=true
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.version=${{ env.VERSION }}
|
||||||
|
|
||||||
|
# Metadata for pre versions
|
||||||
|
- name: Docker meta for pre
|
||||||
|
id: meta-pre
|
||||||
|
if: env.PRE_RELEASE == 'true'
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
aykhans/dodo
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ env.VERSION }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.version=${{ env.VERSION }}
|
||||||
|
|
||||||
|
- name: Build and Push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta-stable.outputs.tags || steps.meta-pre.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-stable.outputs.labels || steps.meta-pre.outputs.labels }}
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.22.6-alpine AS builder
|
FROM golang:1.23.2-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /dodo
|
WORKDIR /dodo
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<h1 align="center">Dodo is a simple and easy-to-use HTTP benchmarking tool.</h1>
|
<h1 align="center">Dodo is a simple and easy-to-use HTTP benchmarking tool.</h1>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img width="30%" height="30%" src="https://raw.githubusercontent.com/aykhans/dodo/main/assets/dodo.png">
|
<img width="30%" height="30%" src="https://ftp.aykhans.me/web/client/pubshares/hB6VSdCnBCr8gFPeiMuCji/browse?path=%2Fdodo.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
BIN
assets/dodo.png
BIN
assets/dodo.png
Binary file not shown.
Before Width: | Height: | Size: 230 KiB |
@ -21,10 +21,6 @@ const (
|
|||||||
MaxDodosCountForProxies uint = 20 // Max dodos count for proxy check
|
MaxDodosCountForProxies uint = 20 // Max dodos count for proxy check
|
||||||
)
|
)
|
||||||
|
|
||||||
type IConfig interface {
|
|
||||||
MergeConfigs(newConfig IConfig) IConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
type RequestConfig struct {
|
type RequestConfig struct {
|
||||||
Method string
|
Method string
|
||||||
URL *url.URL
|
URL *url.URL
|
||||||
@ -48,6 +44,12 @@ func (config *RequestConfig) Print() {
|
|||||||
{Number: 2, WidthMax: 50},
|
{Number: 2, WidthMax: 50},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
newHeaders := make(map[string][]string)
|
||||||
|
newHeaders["User-Agent"] = []string{DefaultUserAgent}
|
||||||
|
for k, v := range config.Headers {
|
||||||
|
newHeaders[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
t.AppendHeader(table.Row{"Request Configuration"})
|
t.AppendHeader(table.Row{"Request Configuration"})
|
||||||
t.AppendRow(table.Row{"Method", config.Method})
|
t.AppendRow(table.Row{"Method", config.Method})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
@ -57,11 +59,11 @@ func (config *RequestConfig) Print() {
|
|||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Dodos", config.DodosCount})
|
t.AppendRow(table.Row{"Dodos", config.DodosCount})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Request", config.RequestCount})
|
t.AppendRow(table.Row{"Requests", config.RequestCount})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Params", utils.MarshalJSON(config.Params, 3)})
|
t.AppendRow(table.Row{"Params", utils.MarshalJSON(config.Params, 3)})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Headers", utils.MarshalJSON(config.Headers, 3)})
|
t.AppendRow(table.Row{"Headers", utils.MarshalJSON(newHeaders, 3)})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)})
|
t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
@ -98,6 +100,26 @@ type Config struct {
|
|||||||
NoProxyCheck utils.Option[bool] `json:"no_proxy_check"`
|
NoProxyCheck utils.Option[bool] `json:"no_proxy_check"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewConfig(
|
||||||
|
method string,
|
||||||
|
timeout uint32,
|
||||||
|
dodosCount uint,
|
||||||
|
requestCount uint,
|
||||||
|
noProxyCheck utils.Option[bool],
|
||||||
|
) *Config {
|
||||||
|
if noProxyCheck == nil {
|
||||||
|
noProxyCheck = utils.NewNoneOption[bool]()
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Config{
|
||||||
|
Method: method,
|
||||||
|
Timeout: timeout,
|
||||||
|
DodosCount: dodosCount,
|
||||||
|
RequestCount: requestCount,
|
||||||
|
NoProxyCheck: noProxyCheck,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (config *Config) MergeConfigs(newConfig *Config) {
|
func (config *Config) MergeConfigs(newConfig *Config) {
|
||||||
if newConfig.Method != "" {
|
if newConfig.Method != "" {
|
||||||
config.Method = newConfig.Method
|
config.Method = newConfig.Method
|
||||||
@ -144,7 +166,7 @@ type Proxy struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type JSONConfig struct {
|
type JSONConfig struct {
|
||||||
Config
|
*Config
|
||||||
Params map[string][]string `json:"params"`
|
Params map[string][]string `json:"params"`
|
||||||
Headers map[string][]string `json:"headers"`
|
Headers map[string][]string `json:"headers"`
|
||||||
Cookies map[string][]string `json:"cookies"`
|
Cookies map[string][]string `json:"cookies"`
|
||||||
@ -152,8 +174,21 @@ type JSONConfig struct {
|
|||||||
Body []string `json:"body"`
|
Body []string `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewJSONConfig(
|
||||||
|
config *Config,
|
||||||
|
params map[string][]string,
|
||||||
|
headers map[string][]string,
|
||||||
|
cookies map[string][]string,
|
||||||
|
proxies []Proxy,
|
||||||
|
body []string,
|
||||||
|
) *JSONConfig {
|
||||||
|
return &JSONConfig{
|
||||||
|
config, params, headers, cookies, proxies, body,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (config *JSONConfig) MergeConfigs(newConfig *JSONConfig) {
|
func (config *JSONConfig) MergeConfigs(newConfig *JSONConfig) {
|
||||||
config.Config.MergeConfigs(&newConfig.Config)
|
config.Config.MergeConfigs(newConfig.Config)
|
||||||
if len(newConfig.Params) != 0 {
|
if len(newConfig.Params) != 0 {
|
||||||
config.Params = newConfig.Params
|
config.Params = newConfig.Params
|
||||||
}
|
}
|
||||||
@ -172,13 +207,23 @@ func (config *JSONConfig) MergeConfigs(newConfig *JSONConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CLIConfig struct {
|
type CLIConfig struct {
|
||||||
Config
|
*Config
|
||||||
Yes bool `json:"yes" validate:"omitempty"`
|
Yes bool `json:"yes" validate:"omitempty"`
|
||||||
ConfigFile string `validation_name:"config-file" validate:"omitempty,filepath"`
|
ConfigFile string `validation_name:"config-file" validate:"omitempty,filepath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewCLIConfig(
|
||||||
|
config *Config,
|
||||||
|
yes bool,
|
||||||
|
configFile string,
|
||||||
|
) *CLIConfig {
|
||||||
|
return &CLIConfig{
|
||||||
|
config, yes, configFile,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (config *CLIConfig) MergeConfigs(newConfig *CLIConfig) {
|
func (config *CLIConfig) MergeConfigs(newConfig *CLIConfig) {
|
||||||
config.Config.MergeConfigs(&newConfig.Config)
|
config.Config.MergeConfigs(newConfig.Config)
|
||||||
if newConfig.ConfigFile != "" {
|
if newConfig.ConfigFile != "" {
|
||||||
config.ConfigFile = newConfig.ConfigFile
|
config.ConfigFile = newConfig.ConfigFile
|
||||||
}
|
}
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/aykhans/dodo
|
module github.com/aykhans/dodo
|
||||||
|
|
||||||
go 1.22.6
|
go 1.23.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-playground/validator/v10 v10.23.0
|
github.com/go-playground/validator/v10 v10.23.0
|
||||||
|
12
main.go
12
main.go
@ -21,8 +21,10 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
validator := validation.NewValidator()
|
validator := validation.NewValidator()
|
||||||
conf := config.Config{}
|
conf := config.NewConfig("", 0, 0, 0, nil)
|
||||||
jsonConf := config.JSONConfig{}
|
jsonConf := config.NewJSONConfig(
|
||||||
|
config.NewConfig("", 0, 0, 0, nil), nil, nil, nil, nil, nil,
|
||||||
|
)
|
||||||
|
|
||||||
cliConf, err := readers.CLIConfigReader()
|
cliConf, err := readers.CLIConfigReader()
|
||||||
if err != nil || cliConf == nil {
|
if err != nil || cliConf == nil {
|
||||||
@ -51,11 +53,11 @@ func main() {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
jsonConf = *jsonConfNew
|
jsonConf = jsonConfNew
|
||||||
conf.MergeConfigs(&jsonConf.Config)
|
conf.MergeConfigs(jsonConf.Config)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.MergeConfigs(&cliConf.Config)
|
conf.MergeConfigs(cliConf.Config)
|
||||||
conf.SetDefaults()
|
conf.SetDefaults()
|
||||||
if err := validator.Struct(conf); err != nil {
|
if err := validator.Struct(conf); err != nil {
|
||||||
utils.PrintErrAndExit(
|
utils.PrintErrAndExit(
|
||||||
|
@ -12,12 +12,8 @@ import (
|
|||||||
|
|
||||||
func CLIConfigReader() (*config.CLIConfig, error) {
|
func CLIConfigReader() (*config.CLIConfig, error) {
|
||||||
var (
|
var (
|
||||||
returnNil = false
|
returnNil = false
|
||||||
cliConfig = &config.CLIConfig{
|
cliConfig = config.NewCLIConfig(config.NewConfig("", 0, 0, 0, nil), false, "")
|
||||||
Config: config.Config{
|
|
||||||
NoProxyCheck: utils.NewNoneOption[bool](),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
dodosCount uint
|
dodosCount uint
|
||||||
requestCount uint
|
requestCount uint
|
||||||
timeout uint32
|
timeout uint32
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/aykhans/dodo/config"
|
"github.com/aykhans/dodo/config"
|
||||||
customerrors "github.com/aykhans/dodo/custom_errors"
|
customerrors "github.com/aykhans/dodo/custom_errors"
|
||||||
"github.com/aykhans/dodo/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func JSONConfigReader(filePath string) (*config.JSONConfig, error) {
|
func JSONConfigReader(filePath string) (*config.JSONConfig, error) {
|
||||||
@ -14,11 +13,10 @@ func JSONConfigReader(filePath string) (*config.JSONConfig, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, customerrors.OSErrorFormater(err)
|
return nil, customerrors.OSErrorFormater(err)
|
||||||
}
|
}
|
||||||
jsonConf := &config.JSONConfig{
|
jsonConf := config.NewJSONConfig(
|
||||||
Config: config.Config{
|
config.NewConfig("", 0, 0, 0, nil),
|
||||||
NoProxyCheck: utils.NewNoneOption[bool](),
|
nil, nil, nil, nil, nil,
|
||||||
},
|
)
|
||||||
}
|
|
||||||
err = json.Unmarshal(data, &jsonConf)
|
err = json.Unmarshal(data, &jsonConf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user