summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-03-24 02:06:15 +0700
committerShulhan <ms@kilabit.info>2021-03-24 02:06:15 +0700
commit19eb62d2f744ea7a08e2e6393e82a67788c3e8ff (patch)
tree63aa56d280b22c4e0b2ddac38d7b46ce911e8382
parent7035a7fb42b9054657f5a99bb479fd4722d8ae7c (diff)
downloadgorankusu-19eb62d2f744ea7a08e2e6393e82a67788c3e8ff.tar.xz
all: fix and update linter warnings
Check for error where it should and remove unused return and methods.
-rw-r--r--attack_result.go8
-rw-r--r--example/example.go10
-rw-r--r--http_target.go4
-rw-r--r--target.go5
-rw-r--r--trunks.go4
5 files changed, 15 insertions, 16 deletions
diff --git a/attack_result.go b/attack_result.go
index 112f2ca..42c4e1e 100644
--- a/attack_result.go
+++ b/attack_result.go
@@ -6,7 +6,6 @@ package trunks
import (
"bytes"
- "encoding/json"
"errors"
"fmt"
"io"
@@ -192,10 +191,3 @@ func (ar *AttackResult) load() (err error) {
return ar.finish()
}
-
-func (ar *AttackResult) pack() (b []byte, err error) {
- ar.mtx.Lock()
- b, err = json.Marshal(ar)
- ar.mtx.Unlock()
- return b, err
-}
diff --git a/example/example.go b/example/example.go
index 851b614..1d6de3e 100644
--- a/example/example.go
+++ b/example/example.go
@@ -175,7 +175,10 @@ func (ex *Example) registerTargets() (err error) {
}},
}
- ex.trunks.RegisterTarget(targetHttp)
+ err = ex.trunks.RegisterTarget(targetHttp)
+ if err != nil {
+ return err
+ }
targetWebSocket := &trunks.Target{
Name: "Example WebSocket",
@@ -193,7 +196,10 @@ func (ex *Example) registerTargets() (err error) {
}},
}
- ex.trunks.RegisterTarget(targetWebSocket)
+ err = ex.trunks.RegisterTarget(targetWebSocket)
+ if err != nil {
+ return err
+ }
return nil
}
diff --git a/http_target.go b/http_target.go
index bb5c370..129bc8e 100644
--- a/http_target.go
+++ b/http_target.go
@@ -96,7 +96,7 @@ func (ht *HttpTarget) deleteResult(result *AttackResult) {
}
}
-func (ht *HttpTarget) addResult(dir, name string) (err error) {
+func (ht *HttpTarget) addResult(dir, name string) {
ar := &AttackResult{
HttpTargetID: ht.ID,
Name: name,
@@ -104,8 +104,6 @@ func (ht *HttpTarget) addResult(dir, name string) (err error) {
}
ht.Results = append(ht.Results, ar)
-
- return nil
}
func (ht *HttpTarget) getResultByName(name string) (result *AttackResult) {
diff --git a/target.go b/target.go
index a0aca87..6bdf4f4 100644
--- a/target.go
+++ b/target.go
@@ -56,7 +56,10 @@ func (target *Target) init() (err error) {
}
for _, wst := range target.WebSocketTargets {
- wst.init()
+ err = wst.init()
+ if err != nil {
+ return fmt.Errorf("Target.init %s: %w", target.Name, err)
+ }
}
return nil
diff --git a/trunks.go b/trunks.go
index 5fcd938..01f7938 100644
--- a/trunks.go
+++ b/trunks.go
@@ -555,10 +555,11 @@ func (trunks *Trunks) scanResultsDir() {
}
}
-func (trunks *Trunks) workerAttackQueue() (err error) {
+func (trunks *Trunks) workerAttackQueue() {
logp := "workerAttackQueue"
for rr := range trunks.attackq {
+ var err error
trunks.Env.AttackRunning = rr
rr.HttpTarget.PreAttack(rr)
@@ -617,5 +618,4 @@ func (trunks *Trunks) workerAttackQueue() (err error) {
trunks.Env.AttackRunning = nil
}
- return nil
}