Skip to content

Commit

Permalink
[*]修复-oJ参数存在的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lcvvvv committed Dec 19, 2022
1 parent de9ce95 commit 5706c43
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/type-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"encoding/json"
"kscan/core/hydra"
"kscan/core/slog"
"kscan/lib/misc"
"os"
"strings"
"sync"
"time"
)

Expand Down Expand Up @@ -40,10 +42,13 @@ type Config struct {
}

type JSONWriter struct {
f *os.File
f *os.File
mutex *sync.Mutex
}

func (jw *JSONWriter) Push(m map[string]string) {
jw.mutex.Lock()
defer jw.mutex.Unlock()
stat, err := jw.f.Stat()
if err != nil {
slog.Println(slog.ERROR, err)
Expand Down Expand Up @@ -153,13 +158,13 @@ func loadOutputJSON(path string) *JSONWriter {
if err != nil {
slog.Println(slog.ERROR, err)
}
jw := &JSONWriter{f}
jw := &JSONWriter{f, &sync.Mutex{}}
jw.f.Seek(0, 0)
_, err = jw.f.WriteString(`[]`)
if err != nil {
slog.Println(slog.ERROR, err)
}
return &JSONWriter{f}
return &JSONWriter{f, &sync.Mutex{}}
}

func loadOutputCSV(path string) *CSVWriter {
Expand Down

0 comments on commit 5706c43

Please sign in to comment.