Skip to content

Commit

Permalink
fix err when using only one field
Browse files Browse the repository at this point in the history
  • Loading branch information
gaopeng2 committed Dec 31, 2021
1 parent 06b5b07 commit fa6053d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions internal/fofa/fofa_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool {
printer.Errorf(printer.HandlerLine("request failed: " + err.Error()))
return false
}
if f.option.FetchFields != cli.DefaultField {
printer.Debugf("Fields : %s", strings.Join(strings.Split(f.option.FetchFields, ","), f.option.FetchFieldsSplit))
}
req.Header.Set("fofax-client-%s", cli.FoFaXVersion)
// 计算时长
start := time.Now().UnixMilli()
Expand All @@ -135,7 +138,7 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool {
printer.Errorf(printer.HandlerLine("body read failed: " + err.Error()))
}
if f.option.Debug {
printer.Debugf("Resp Time: %f/millis", float64(time.Now().UnixMilli()-start))
printer.Debugf("Resp Time: %.2f/millis", float64(time.Now().UnixMilli()-start))
}

var apiResult ApiResults
Expand All @@ -151,9 +154,7 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool {
printer.Debugf("Fofa Api Query: %s", apiResult.Query)
}
printer.Successf("Fetch Data From FoFa: [%d/%d]", len(apiResult.Results), apiResult.Size)
if f.option.FetchFields != cli.DefaultField {
fmt.Println(strings.Join(strings.Split(f.option.FetchFields, ","), f.option.FetchFieldsSplit))
}

for _, result := range apiResult.Results {
//if len(result[0]) == 0 || result[0] == ":0" {
// printer.Debug("There is no HostInfo!")
Expand Down
5 changes: 2 additions & 3 deletions internal/runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,10 @@ func (r *Runner) Run() *sync.Map {
fo.FetchJarmOfDomain(fofaQuery)
} else if r.options.FetchFields != cli.DefaultField {
fo.FetchFn = func(fields []string, allSize int32) bool {
r.resMap.LoadOrStore(strings.Join(fields, r.options.FetchFieldsSplit), nil)

r.resMap.LoadOrStore(strings.Join(fields[:len(fields)-1], r.options.FetchFieldsSplit), nil)
return true
}
fo.FetchField(r.options.FetchFields, fofaQuery)
fo.FetchField(r.options.FetchFields+",type", fofaQuery)
} else {
fo.FetchFn = func(fields []string, allSize int32) bool {
fullUrl, err := utils.NewFixUrl(fields[0])
Expand Down

0 comments on commit fa6053d

Please sign in to comment.