Skip to content

Commit

Permalink
Use widgets instead of drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Sep 15, 2020
1 parent bde0524 commit 8965080
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Executables are available through the [releases page](https://github.com/nakabon


## LoadMap
- Support more options for HTTP requests
- Plot Bytes In and Bytes Out (Press `Ctrl-w` to switch between charts)
- Plot status codes
- Better UI
Expand Down
2 changes: 1 addition & 1 deletion gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func attack(ctx context.Context, d *drawer) {
d.reportCh <- fmt.Sprintf("Bad URL: %v", err)
return
}
opts, err := makeOptions(d)
opts, err := makeOptions(d.widgets)
if err != nil {
d.reportCh <- err.Error()
return
Expand Down
12 changes: 6 additions & 6 deletions gui/input_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// makeOptions gives back an options for attacker, with the input from UI.
func makeOptions(d *drawer) (attacker.Options, error) {
func makeOptions(w *widgets) (attacker.Options, error) {
var (
rate int
duration time.Duration
Expand All @@ -21,7 +21,7 @@ func makeOptions(d *drawer) (attacker.Options, error) {
err error
)

if s := d.widgets.rateLimitInput.Read(); s == "" {
if s := w.rateLimitInput.Read(); s == "" {
rate = attacker.DefaultRate
} else {
rate, err = strconv.Atoi(s)
Expand All @@ -30,7 +30,7 @@ func makeOptions(d *drawer) (attacker.Options, error) {
}
}

if s := d.widgets.durationInput.Read(); s == "" {
if s := w.durationInput.Read(); s == "" {
duration = attacker.DefaultDuration
} else {
duration, err = time.ParseDuration(s)
Expand All @@ -39,15 +39,15 @@ func makeOptions(d *drawer) (attacker.Options, error) {
}
}

if method = d.widgets.methodInput.Read(); method != "" {
if method = w.methodInput.Read(); method != "" {
if !validateMethod(method) {
return attacker.Options{}, fmt.Errorf("Given method %q isn't an HTTP request method", method)
}
}

body = d.widgets.bodyInput.Read()
body = w.bodyInput.Read()

if s := d.widgets.headerInput.Read(); s != "" {
if s := w.headerInput.Read(); s != "" {
parts := strings.SplitN(s, ":", 2)
if len(parts) != 2 {
return attacker.Options{}, fmt.Errorf("Given header %q has a wrong format", s)
Expand Down

0 comments on commit 8965080

Please sign in to comment.