From 3209221c94634a3e49bad6c90896919745be8e85 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 16 Feb 2024 01:35:08 +0700 Subject: target: changes Opts to non-pointer Previously, we use pointer to indicated that the Target can be attacked or not. Since HTTPTarget now have AllowAttack, this options can be changes to non-pointer. --- example.go | 3 +-- run_request.go | 2 +- target.go | 7 ++----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/example.go b/example.go index 73c97f3..60bed1c 100644 --- a/example.go +++ b/example.go @@ -209,7 +209,7 @@ func (ex *Example) registerTargetHTTP() (err error) { Name: `Example HTTP`, Hint: `This section provide an example of HTTP endpoints that can be tested and attacked.`, BaseURL: fmt.Sprintf(`http://%s`, ex.Gorankusu.Env.ListenAddress), - Opts: &AttackOptions{ + Opts: AttackOptions{ Duration: 10 * time.Second, RatePerSecond: 1, }, @@ -412,7 +412,6 @@ func (ex *Example) registerTargetWebSocket() (err error) { Name: `Example WebSocket`, Hint: `This section provide an example of WebSocket endpoints that can be tested.`, BaseURL: fmt.Sprintf(`ws://%s`, websocketAddress), - Opts: &AttackOptions{}, Vars: KeyFormInput{ `WebSocketVar`: FormInput{ Label: `WebSocketVar`, diff --git a/run_request.go b/run_request.go index d999ff8..0ddaafc 100644 --- a/run_request.go +++ b/run_request.go @@ -14,9 +14,9 @@ import ( type RunRequest struct { result *AttackResult - Target Target WebSocketTarget WebSocketTarget HTTPTarget HTTPTarget + Target Target } // generateRunRequest merge the [RunRequest] req from WUI with original diff --git a/target.go b/target.go index 6214dfe..13d4571 100644 --- a/target.go +++ b/target.go @@ -14,7 +14,6 @@ type Target struct { // HTTPClient that can be used for running HTTPTarget. HTTPClient *libhttp.Client `json:"-"` - Opts *AttackOptions Vars KeyFormInput ID string @@ -29,6 +28,8 @@ type Target struct { HTTPTargets []*HTTPTarget WebSocketTargets []*WebSocketTarget + + Opts AttackOptions } func (target *Target) init() (err error) { @@ -41,10 +42,6 @@ func (target *Target) init() (err error) { target.ID = generateID(target.Name) - if target.Opts == nil { - target.Opts = &AttackOptions{} - } - target.Opts.init() if target.Vars == nil { -- cgit v1.3